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:
authorisaacs <i@izs.me>2013-06-21 00:12:36 +0400
committerisaacs <i@izs.me>2013-06-21 00:12:36 +0400
commit9374aa81b4b0d0be3d08f19f0d9d9fc85771b77d (patch)
tree9b710b3c100039b617a0e5ce868daf6001f4f63b /node_modules/read-package-json
parent8ee81f99f4226b20c43d791788fa5b629aa1f83e (diff)
read-package-json@1.1.0
Diffstat (limited to 'node_modules/read-package-json')
-rw-r--r--node_modules/read-package-json/README.md10
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/README.md1
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js153
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/lib/is_valid.js58
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js14
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/lib/typos.json3
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/package.json10
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/test/normalize.js61
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/test/strict.js54
-rw-r--r--node_modules/read-package-json/node_modules/normalize-package-data/test/typo.js49
-rw-r--r--node_modules/read-package-json/package.json12
-rw-r--r--node_modules/read-package-json/read-json.js60
12 files changed, 335 insertions, 150 deletions
diff --git a/node_modules/read-package-json/README.md b/node_modules/read-package-json/README.md
index 97fb19f13..36b72a26d 100644
--- a/node_modules/read-package-json/README.md
+++ b/node_modules/read-package-json/README.md
@@ -17,7 +17,8 @@ npm will see when it looks at your package.
```javascript
var readJson = require('read-package-json')
-readJson('/path/to/package.json', function (er, data) {
+// readJson(filename, [logFunction=noop], [strict=false], cb)
+readJson('/path/to/package.json', console.error, false, function (er, data) {
if (er) {
console.error("There was an error reading the file")
return
@@ -27,10 +28,13 @@ readJson('/path/to/package.json', function (er, data) {
}
```
-## readJson(file, cb)
+## readJson(file, [logFn = noop], [strict = false], cb)
* `file` {String} The path to the package.json file
-* `cb` {Function}
+* `logFn` {Function} Function to handle logging. Defaults to a noop.
+* `strict` {Boolean} True to enforce SemVer 2.0 version strings, and
+ other strict requirements.
+* `cb` {Function} Gets called with `(er, data)`, as is The Node Way.
Reads the JSON file and does the things.
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/README.md b/node_modules/read-package-json/node_modules/normalize-package-data/README.md
index 5712bd9ee..71fa95065 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/README.md
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/README.md
@@ -56,6 +56,7 @@ If the supplied data has an invalid name or version vield, `normalizeData` will
* 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.
* If `homepage` field is not a string, it will be removed.
+* If the url in the `homepage` field does not specify a protocol, then http is assumed. For example, `myproject.org` will be changed to `http://myproject.org`.
### Rules for name field
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js b/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js
index b42b30eee..d322a31b4 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js
@@ -3,15 +3,19 @@ var parseGitHubURL = require("github-url-from-git")
var depTypes = ["dependencies","devDependencies","optionalDependencies"]
var extractDescription = require("./extract_description")
var url = require("url")
+var typos = require("./typos")
var fixer = module.exports = {
+ // default warning function
+ warn: function() {},
+
fixRepositoryField: function(data) {
if (data.repositories) {
this.warn("'repositories' (plural) Not supported.\n" +
"Please pick one as the 'repository' field");
data.repository = data.repositories[0]
}
- if (!data.repository) return;
+ if (!data.repository) return this.warn('No repository field.')
if (typeof data.repository === "string") {
data.repository = {
type: "git",
@@ -31,11 +35,44 @@ var fixer = module.exports = {
}
}
+, fixTypos: function(data) {
+ Object.keys(typos.topLevel).forEach(function (d) {
+ if (data.hasOwnProperty(d)) {
+ this.warn(makeTypoWarning(d, typos.topLevel[d]))
+ }
+ }, this)
+ }
+
+, fixScriptsField: function(data) {
+ if (!data.scripts) return
+ if (typeof data.scripts !== "object") {
+ this.warn("scripts must be an object")
+ delete data.scripts
+ }
+ Object.keys(data.scripts).forEach(function (k) {
+ if (typeof data.scripts[k] !== "string") {
+ this.warn("script values must be string commands")
+ delete data.scripts[k]
+ } else if (typos.script[k]) {
+ this.warn(makeTypoWarning(k, typos.script[k], "scripts"))
+ }
+ }, this)
+ }
+
, fixFilesField: function(data) {
var files = data.files
if (files && !Array.isArray(files)) {
this.warn("Invalid 'files' member")
delete data.files
+ } else if (data.files) {
+ data.files = data.files.filter(function(file) {
+ if (!file || typeof file !== "string") {
+ this.warn("Invalid filename in 'files' list: " + file)
+ return false
+ } else {
+ return true
+ }
+ }, this)
}
}
@@ -61,29 +98,83 @@ var fixer = module.exports = {
data[bd] = data[bdd]
delete data[bdd]
}
+ if (data[bd] && !Array.isArray(data[bd])) {
+ this.warn("Invalid 'bundleDependencies' list. " +
+ "Must be array of package names")
+ delete data[bd]
+ } else if (data[bd]) {
+ data[bd] = data[bd].filter(function(bd) {
+ if (!bd || typeof bd !== 'string') {
+ this.warn("Invalid bundleDependencies member: " + bd)
+ return false
+ } else {
+ return true
+ }
+ }, this)
+ }
}
-, fixDependencies: function(data) {
+, fixDependencies: function(data, strict) {
+ var loose = !strict
objectifyDeps(data, this.warn)
addOptionalDepsToDeps(data, this.warn)
this.fixBundleDependenciesField(data)
+
+ ;['dependencies','devDependencies'].forEach(function(deps) {
+ if (!(deps in data)) return
+ if (!data[deps] || typeof data[deps] !== "object") {
+ this.warn(deps + " field must be an object")
+ delete data[deps]
+ return
+ }
+ Object.keys(data[deps]).forEach(function (d) {
+ var r = data[deps][d]
+ if (typeof r !== 'string') {
+ this.warn('Invalid dependency: ' + d + ' ' + JSON.stringify(r))
+ delete data[deps][d]
+ }
+ }, this)
+ }, this)
}
-, fixKeywordsField: function (data, warn) {
+, fixModulesField: function (data) {
+ if (data.modules) {
+ this.warn("modules field is deprecated")
+ delete data.modules
+ }
+ }
+
+, fixKeywordsField: function (data) {
if (typeof data.keywords === "string") {
data.keywords = data.keywords.split(/,\s+/)
}
+ if (data.keywords && !Array.isArray(data.keywords)) {
+ delete data.keywords
+ this.warn("keywords should be an array of strings")
+ } else if (data.keywords) {
+ data.keywords = data.keywords.filter(function(kw) {
+ if (typeof kw !== "string" || !kw) {
+ this.warn("keywords should be an array of strings");
+ return false
+ } else {
+ return true
+ }
+ }, this)
+ }
}
-, fixVersionField: function(data) {
+, fixVersionField: function(data, strict) {
+ // allow "loose" semver 1.0 versions in non-strict mode
+ // enforce strict semver 2.0 compliance in strict mode
+ var loose = !strict
if (!data.version) {
data.version = ""
return true
}
- if (!semver.valid(data.version)) {
- throw new Error("invalid version: "+ data.version)
+ if (!semver.valid(data.version, loose)) {
+ throw new Error('Invalid version: "'+ data.version + '"')
}
- data.version = semver.clean(data.version)
+ data.version = semver.clean(data.version, loose)
return true
}
@@ -92,16 +183,17 @@ var fixer = module.exports = {
modifyPeople(data, parsePerson)
}
-, fixNameField: function(data) {
- if (!data.name) {
+, fixNameField: function(data, strict) {
+ if (!data.name && !strict) {
data.name = ""
- return true
+ return
}
if (typeof data.name !== "string") {
throw new Error("name field must be a string.")
}
- data.name = data.name.trim()
- ensureValidName(data.name)
+ if (!strict)
+ data.name = data.name.trim()
+ ensureValidName(data.name, strict)
}
@@ -112,10 +204,14 @@ var fixer = module.exports = {
}
if (data.readme && !data.description)
data.description = extractDescription(data.readme)
+ if (!data.description) this.warn('No description')
}
, fixReadmeField: function (data) {
- if (!data.readme) data.readme = "ERROR: No README data found!"
+ if (!data.readme) {
+ this.warn("No README data")
+ data.readme = "ERROR: No README data found!"
+ }
}
, fixBugsField: function(data) {
@@ -139,6 +235,7 @@ var fixer = module.exports = {
this.warn("Bug string field must be url, email, or {email,url}")
}
else {
+ bugsTypos(data.bugs, this.warn)
var oldBugs = data.bugs
data.bugs = {}
if(oldBugs.url) {
@@ -163,17 +260,22 @@ var fixer = module.exports = {
, fixHomepageField: function(data) {
if(!data.homepage) return true;
- if(typeof data.homepage !== "string" || !url.parse(data.homepage).protocol) {
+ if(typeof data.homepage !== "string") {
this.warn("homepage field must be a string url. Deleted.")
- delete data.homepage
+ return delete data.homepage
+ }
+ if(!url.parse(data.homepage).protocol) {
+ this.warn("homepage field must start with a protocol.")
+ data.homepage = "http://" + data.homepage
}
}
}
-function ensureValidName (name) {
+function ensureValidName (name, strict) {
if (name.charAt(0) === "." ||
name.match(/[\/@\s\+%:]/) ||
name !== encodeURIComponent(name) ||
+ (strict && name !== name.toLowerCase()) ||
name.toLowerCase() === "node_modules" ||
name.toLowerCase() === "favicon.ico") {
throw new Error("Invalid name: " + JSON.stringify(name))
@@ -247,3 +349,22 @@ function objectifyDeps (data, warn) {
data[type] = depObjectify(data[type])
})
}
+
+function bugsTypos(bugs, warn) {
+ if (!bugs) return
+ Object.keys(bugs).forEach(function (k) {
+ if (typos.bugs[k]) {
+ warn(makeTypoWarning(k, typos.bugs[k], "bugs"))
+ bugs[typos.bugs[k]] = bugs[k]
+ delete bugs[k]
+ }
+ })
+}
+
+function makeTypoWarning (providedName, probableName, field) {
+ if (field) {
+ providedName = field + "['" + providedName + "']"
+ probableName = field + "['" + probableName + "']"
+ }
+ return providedName + " should probably be " + probableName + "."
+}
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/lib/is_valid.js b/node_modules/read-package-json/node_modules/normalize-package-data/lib/is_valid.js
deleted file mode 100644
index 509fab491..000000000
--- a/node_modules/read-package-json/node_modules/normalize-package-data/lib/is_valid.js
+++ /dev/null
@@ -1,58 +0,0 @@
-// a warning for deprecated or likely-incorrect fields
-
-module.exports = isValid
-
-var typos = require("./typos")
-
-function isValid (data, warnFunc) {
- var hasWarned = false
- function warn(msg) {
- hasWarned = true
- if(warnFunc) warnFunc(msg)
- }
- if (data.modules) warn("'modules' is deprecated")
- Object.keys(typos.topLevel).forEach(function (d) {
- if (data.hasOwnProperty(d)) {
- warn(makeTypoWarning(d, typos.topLevel[d]))
- }
- })
- checkBugsField(data.bugs, warn)
- checkScriptsField(data.scripts, warn)
- if (!data.repository) warn("No repository field.")
- if (!data.readme) warn("No readme data.")
- if (data.description && typeof data.description !== 'string') {
- warn("'description' field should be a string")
- }
- if (data[data.bundledDependencies] &&
- !Array.isArray(data.bundleDependencies)) {
- warn("bundleDependencies must be an array")
- }
- return !hasWarned
-}
-
-function checkBugsField (bugs, warn) {
- if (!bugs || typeof bugs !== "object") return
- Object.keys(bugs).forEach(function (k) {
- if (typos.bugs[k]) {
- bugs[typos.bugs[k]] = bugs[k]
- delete bugs[k]
- }
- })
-}
-
-function checkScriptsField (scripts, warn) {
- if (!scripts || typeof scripts !== "object") return
- Object.keys(scripts).forEach(function (k) {
- if (typos.script[k]) {
- warn(makeTypoWarning(k, typos.script[k], "scripts"))
- }
- })
-}
-
-function makeTypoWarning (providedName, probableName, field) {
- if (field) {
- providedName = field + "['" + providedName + "']"
- probableName = field + "['" + probableName + "']"
- }
- return providedName + " should probably be " + probableName + "."
-}
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js b/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js
index 336334a47..5ff5b6395 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js
@@ -1,11 +1,10 @@
module.exports = normalize
-var isValid = require("./is_valid")
var fixer = require("./fixer")
-var fieldsToFix = ['name','version','description','repository'
+var fieldsToFix = ['name','version','description','repository','modules','scripts'
,'files','bin','man','bugs','keywords','readme','homepage']
-var otherThingsToFix = ['dependencies','people']
+var otherThingsToFix = ['dependencies','people', 'typos']
var thingsToFix = fieldsToFix.map(function(fieldName) {
return ucFirst(fieldName) + "Field"
@@ -15,9 +14,11 @@ var thingsToFix = fieldsToFix.map(function(fieldName) {
// thingsToFix = (ucFirst(name) + "Field" for name in fieldsToFix)
thingsToFix = thingsToFix.concat(otherThingsToFix)
-function normalize (data, warn) {
+function normalize (data, warn, strict) {
+ if(warn === true) warn = null, strict = true
+ if(!strict) strict = false
if(!warn) warn = function(msg) { /* noop */ }
- isValid(data, warn) // don't care if it's valid, we'll make it valid
+
if (data.scripts &&
data.scripts.install === "node-gyp rebuild" &&
!data.scripts.preinstall) {
@@ -25,10 +26,9 @@ function normalize (data, warn) {
}
fixer.warn = warn
thingsToFix.forEach(function(thingName) {
- fixer["fix" + ucFirst(thingName)](data)
+ fixer["fix" + ucFirst(thingName)](data, strict)
})
data._id = data.name + "@" + data.version
- if (data.modules) delete data.modules // modules field is deprecated
}
function ucFirst (string) {
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/lib/typos.json b/node_modules/read-package-json/node_modules/normalize-package-data/lib/typos.json
index dd2ec6614..6dc59e6a9 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/lib/typos.json
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/lib/typos.json
@@ -17,7 +17,8 @@
,"autor": "author"
,"contributers": "contributors"
,"publicationConfig": "publishConfig"
+ ,"script": "scripts"
},
"bugs": { "web": "url", "name": "url" },
"script": { "server": "start", "tests": "test" }
-} \ No newline at end of file
+}
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/package.json b/node_modules/read-package-json/node_modules/normalize-package-data/package.json
index 0479feac5..cf8acaaf9 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/package.json
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/package.json
@@ -1,6 +1,6 @@
{
"name": "normalize-package-data",
- "version": "0.1.6",
+ "version": "0.2.0",
"author": {
"name": "Meryn Stol",
"email": "merynstol@gmail.com"
@@ -15,7 +15,7 @@
"test": "tap test/*.js"
},
"dependencies": {
- "semver": "1.x",
+ "semver": "2",
"github-url-from-git": "~1.1.1"
},
"devDependencies": {
@@ -33,11 +33,11 @@
"email": "merynstol@gmail.com"
}
],
- "readme": "# normalize-package-data [![Build Status](https://travis-ci.org/meryn/normalize-package-data.png?branch=master)](https://travis-ci.org/meryn/normalize-package-data)\n\nnormalize-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.\n\nnormalize-package-data is used by [read-package-json](https://npmjs.org/package/read-package-json) to normalize the data it reads from a package.json file. In turn, read-package-json is used by [npm](https://npmjs.org/package/npm) and various npm-related tools.\n\n## Installation\n\n```\nnpm install normalize-package-data\n```\n\n## Usage\n\nBasic usage is really simple. You call the function that normalize-package-data exports. Let's call it `normalizeData`.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nnormalizeData(packageData)\n// packageData is now normalized\n```\n\nOptionally, you may pass a \"warning\" function. It gets called whenever the normalizeData function encounters something that doesn't look right. It indicates less than perfect input data.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nwarnFn = function(msg) { console.error(msg) }\nnormalizeData(packageData, warnFn)\n// packageData is now normalized. Any number of warnings may have been logged.\n```\n\nIf you don't provide a warning function, `normalizeData` functions silently.\n\n### Potential exceptions\n\nIf the supplied data has an invalid name or version vield, `normalizeData` will throw an error. Depending on where you call `normalizeData`, you may want to catch these errors so can pass them to a callback.\n\n## What normalization (currently) entails\n\n* The value of `name` field gets trimmed.\n* The value of the `version` field gets cleaned by `semver.clean`. See [documentation for the semver module](https://github.com/isaacs/node-semver).\n* If `name` and/or `version` fields are missing, they are set to empty strings.\n* If `files` field is not an array, it will be removed.\n* If `bin` field is a string, then `bin` field will become an object with `name` set to the value of the `name` field, and `bin` set to the original string value.\n* If `man` field is a string, it will become an array with the original string as its sole member.\n* If `keywords` field is string, it is considered to be a list of keywords separated by one or more white-space characters. It gets converted to an array by splitting on `\\s+`.\n* All people fields (`author`, `maintainers`, `contributors`) get converted into objects with name, email and url properties.\n* If `bundledDependencies` field (a typo) exists and `bundleDependencies` field does not, `bundledDependencies` will get renamed to `bundleDependencies`.\n* 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.\n* The values in `optionalDependencies` get added to `dependencies`. The `optionalDependencies` array is left untouched.\n* If `description` field does not exists, 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`.\n* If `repository` field is a string, it will become an object with `url` set to the original string value, and `type` set to `\"git\"`.\n* If `bugs` field is a string, the value of `bugs` field is changed into an object with `url` set to the original string value.\n* 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.\n* 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.\n* If `homepage` field is not a string, it will be removed.\n\n### Rules for name field\n\nIf `name` field is given, the value of the name field must be a string. The string may not:\n\n* start with a period.\n* contain the following characters: `/@\\s+%`\n* contain and characters that would need to be encoded for use in urls.\n* resemble the word `node_modules` or `favicon.ico` (case doesn't matter).\n\n### Rules for version field\n\nIf `version` field is given, the value of the version field must be a valid *semver* string, as determined by the `semver.valid` method. See [documentation for the semver module](https://github.com/isaacs/node-semver).\n\n## Credits\n\nThis package contains code based on read-package-json written by Isaac Z. Schlueter. Used with permisson.\n\n## License\n\nnormalize-package-data is released under the [BSD 2-Clause License](http://opensource.org/licenses/MIT). \nCopyright (c) 2013 Meryn Stol ",
+ "readme": "# normalize-package-data [![Build Status](https://travis-ci.org/meryn/normalize-package-data.png?branch=master)](https://travis-ci.org/meryn/normalize-package-data)\n\nnormalize-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.\n\nnormalize-package-data is used by [read-package-json](https://npmjs.org/package/read-package-json) to normalize the data it reads from a package.json file. In turn, read-package-json is used by [npm](https://npmjs.org/package/npm) and various npm-related tools.\n\n## Installation\n\n```\nnpm install normalize-package-data\n```\n\n## Usage\n\nBasic usage is really simple. You call the function that normalize-package-data exports. Let's call it `normalizeData`.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nnormalizeData(packageData)\n// packageData is now normalized\n```\n\nOptionally, you may pass a \"warning\" function. It gets called whenever the normalizeData function encounters something that doesn't look right. It indicates less than perfect input data.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nwarnFn = function(msg) { console.error(msg) }\nnormalizeData(packageData, warnFn)\n// packageData is now normalized. Any number of warnings may have been logged.\n```\n\nIf you don't provide a warning function, `normalizeData` functions silently.\n\n### Potential exceptions\n\nIf the supplied data has an invalid name or version vield, `normalizeData` will throw an error. Depending on where you call `normalizeData`, you may want to catch these errors so can pass them to a callback.\n\n## What normalization (currently) entails\n\n* The value of `name` field gets trimmed.\n* The value of the `version` field gets cleaned by `semver.clean`. See [documentation for the semver module](https://github.com/isaacs/node-semver).\n* If `name` and/or `version` fields are missing, they are set to empty strings.\n* If `files` field is not an array, it will be removed.\n* If `bin` field is a string, then `bin` field will become an object with `name` set to the value of the `name` field, and `bin` set to the original string value.\n* If `man` field is a string, it will become an array with the original string as its sole member.\n* If `keywords` field is string, it is considered to be a list of keywords separated by one or more white-space characters. It gets converted to an array by splitting on `\\s+`.\n* All people fields (`author`, `maintainers`, `contributors`) get converted into objects with name, email and url properties.\n* If `bundledDependencies` field (a typo) exists and `bundleDependencies` field does not, `bundledDependencies` will get renamed to `bundleDependencies`.\n* 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.\n* The values in `optionalDependencies` get added to `dependencies`. The `optionalDependencies` array is left untouched.\n* If `description` field does not exists, 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`.\n* If `repository` field is a string, it will become an object with `url` set to the original string value, and `type` set to `\"git\"`.\n* If `bugs` field is a string, the value of `bugs` field is changed into an object with `url` set to the original string value.\n* 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.\n* 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.\n* If `homepage` field is not a string, it will be removed.\n* If the url in the `homepage` field does not specify a protocol, then http is assumed. For example, `myproject.org` will be changed to `http://myproject.org`.\n\n### Rules for name field\n\nIf `name` field is given, the value of the name field must be a string. The string may not:\n\n* start with a period.\n* contain the following characters: `/@\\s+%`\n* contain and characters that would need to be encoded for use in urls.\n* resemble the word `node_modules` or `favicon.ico` (case doesn't matter).\n\n### Rules for version field\n\nIf `version` field is given, the value of the version field must be a valid *semver* string, as determined by the `semver.valid` method. See [documentation for the semver module](https://github.com/isaacs/node-semver).\n\n## Credits\n\nThis package contains code based on read-package-json written by Isaac Z. Schlueter. Used with permisson.\n\n## License\n\nnormalize-package-data is released under the [BSD 2-Clause License](http://opensource.org/licenses/MIT). \nCopyright (c) 2013 Meryn Stol ",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/meryn/normalize-package-data/issues"
},
- "_id": "normalize-package-data@0.1.6",
- "_from": "normalize-package-data@~0.1.2"
+ "_id": "normalize-package-data@0.2.0",
+ "_from": "normalize-package-data@~0.2"
}
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/test/normalize.js b/node_modules/read-package-json/node_modules/normalize-package-data/test/normalize.js
index b015a6a49..099faf3f7 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/test/normalize.js
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/test/normalize.js
@@ -47,7 +47,11 @@ tap.test("empty object", function(t) {
}
normalize(packageData, warn)
t.same(packageData, expect)
- t.same(warnings, ["No repository field.","No readme data."])
+ t.same(warnings, [
+ "No description",
+ "No repository field.",
+ "No README data"
+ ])
t.end()
})
@@ -65,7 +69,7 @@ tap.test("urls required", function(t) {
var a
normalize(a={
readme: "read yourself how about",
- homepage: "stragle planarf",
+ homepage: 123,
bugs: "what is this i don't even",
repository: "Hello."
}, warn)
@@ -73,18 +77,41 @@ tap.test("urls required", function(t) {
console.error(a)
var expect =
- [ 'No repository field.',
- 'No readme data.',
- 'bugs.url field must be a string url. Deleted.',
- 'bugs.email field must be a string email. Deleted.',
- 'Normalized value of bugs field is an empty object. Deleted.',
- 'Bug string field must be url, email, or {email,url}',
- 'Normalized value of bugs field is an empty object. Deleted.',
- 'homepage field must be a string url. Deleted.' ]
+ [ "No description",
+ "No repository field.",
+ "bugs.url field must be a string url. Deleted.",
+ "bugs.email field must be a string email. Deleted.",
+ "Normalized value of bugs field is an empty object. Deleted.",
+ "No README data",
+ "Bug string field must be url, email, or {email,url}",
+ "Normalized value of bugs field is an empty object. Deleted.",
+ "homepage field must be a string url. Deleted." ]
t.same(warnings, expect)
t.end()
})
+tap.test("homepage field must start with a protocol.", function(t) {
+ var warnings = []
+ function warn(w) {
+ warnings.push(w)
+ }
+ var a
+ normalize(a={
+ homepage: 'example.org'
+ }, warn)
+
+ console.error(a)
+
+ var expect =
+ [ "No description",
+ "No repository field.",
+ "No README data",
+ "homepage field must start with a protocol." ]
+ t.same(warnings, expect)
+ t.same(a.homepage, 'http://example.org')
+ t.end()
+})
+
tap.test("gist bugs url", function(t) {
var d = {
repository: "git@gist.github.com:123456.git"
@@ -95,14 +122,14 @@ tap.test("gist bugs url", function(t) {
t.end();
});
-tap.test('no new globals', function(t) {
- t.same(Object.keys(global), globals)
- t.end()
-})
-
tap.test("singularize repositories", function(t) {
- d = {repositories:["git@gist.github.com:123456.git"]}
+ 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.end()
-}); \ No newline at end of file
+});
+
+tap.test('no new globals', function(t) {
+ t.same(Object.keys(global), globals)
+ t.end()
+})
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/test/strict.js b/node_modules/read-package-json/node_modules/normalize-package-data/test/strict.js
new file mode 100644
index 000000000..40e09dcf2
--- /dev/null
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/test/strict.js
@@ -0,0 +1,54 @@
+var test = require("tap").test
+
+var normalize = require("../")
+
+test("strict", function(t) {
+ var threw
+
+ try {
+ threw = false
+ normalize({name: "X"}, true)
+ } catch (er) {
+ threw = true
+ t.equal(er.message, 'Invalid name: "X"')
+ } finally {
+ t.equal(threw, true)
+ }
+
+ try {
+ threw = false
+ normalize({name:" x "}, true)
+ } catch (er) {
+ threw = true
+ t.equal(er.message, 'Invalid name: " x "')
+ } finally {
+ t.equal(threw, true)
+ }
+
+ try {
+ threw = false
+ normalize({name:"x",version:"01.02.03"}, true)
+ } catch (er) {
+ threw = true
+ t.equal(er.message, 'Invalid version: "01.02.03"')
+ } finally {
+ t.equal(threw, true)
+ }
+
+ // these should not throw
+ var slob = {name:" X ",version:"01.02.03",dependencies:{
+ y:">01.02.03",
+ z:"! 99 $$ASFJ(Aawenf90awenf as;naw.3j3qnraw || an elephant"
+ }}
+ normalize(slob, false)
+ t.same(slob,
+ { name: 'X',
+ version: '1.2.3',
+ dependencies:
+ { y: '>01.02.03',
+ z: '! 99 $$ASFJ(Aawenf90awenf as;naw.3j3qnraw || an elephant' },
+ readme: 'ERROR: No README data found!',
+ _id: 'X@1.2.3' })
+
+ t.end()
+})
diff --git a/node_modules/read-package-json/node_modules/normalize-package-data/test/typo.js b/node_modules/read-package-json/node_modules/normalize-package-data/test/typo.js
index d7d3af0e2..72932e949 100644
--- a/node_modules/read-package-json/node_modules/normalize-package-data/test/typo.js
+++ b/node_modules/read-package-json/node_modules/normalize-package-data/test/typo.js
@@ -9,7 +9,8 @@ test('typos', function(t) {
}
var expect =
- [ 'dependancies should probably be dependencies.',
+ [ 'No repository field.',
+ 'dependancies should probably be dependencies.',
'dependecies should probably be dependencies.',
'depdenencies should probably be dependencies.',
'devEependencies should probably be devDependencies.',
@@ -25,14 +26,7 @@ test('typos', function(t) {
'autohr should probably be author.',
'autor should probably be author.',
'contributers should probably be contributors.',
- 'publicationConfig should probably be publishConfig.',
- 'No repository field.',
- 'No repository field.',
- 'No readme data.',
- 'bugs.url field must be a string url. Deleted.',
- 'Normalized value of bugs field is an empty object. Deleted.',
- 'No repository field.',
- 'No readme data.' ]
+ 'publicationConfig should probably be publishConfig.' ]
normalize({"dependancies": "dependencies"
,"dependecies": "dependencies"
@@ -55,13 +49,50 @@ test('typos', function(t) {
,name:"name"
,version:"1.2.5"}, warn)
+ t.same(warnings, expect)
+
+ warnings.length = 0
+ var expect =
+ [ 'No description',
+ 'No repository field.',
+ 'bugs[\'web\'] should probably be bugs[\'url\'].',
+ 'bugs[\'name\'] should probably be bugs[\'url\'].',
+ 'bugs.url field must be a string url. Deleted.',
+ 'Normalized value of bugs field is an empty object. Deleted.',
+ "No README data" ]
+
normalize({name:"name"
,version:"1.2.5"
,bugs:{web:"url",name:"url"}}, warn)
+ t.same(warnings, expect)
+
+ warnings.length = 0
+ var expect =
+ [ 'No description',
+ 'No repository field.',
+ "No README data",
+ 'script should probably be scripts.' ]
+
normalize({name:"name"
,version:"1.2.5"
,script:{server:"start",tests:"test"}}, warn)
+
+ t.same(warnings, expect)
+
+ warnings.length = 0
+ expect =
+ [ 'No description',
+ 'No repository field.',
+ 'scripts[\'server\'] should probably be scripts[\'start\'].',
+ 'scripts[\'tests\'] should probably be scripts[\'test\'].',
+ "No README data" ]
+
+ normalize({name:"name"
+ ,version:"1.2.5"
+ ,scripts:{server:"start",tests:"test"}}, warn)
+
t.same(warnings, expect)
+
t.end();
})
diff --git a/node_modules/read-package-json/package.json b/node_modules/read-package-json/package.json
index 6a2796e0b..45fb140e3 100644
--- a/node_modules/read-package-json/package.json
+++ b/node_modules/read-package-json/package.json
@@ -1,6 +1,6 @@
{
"name": "read-package-json",
- "version": "0.4.1",
+ "version": "1.1.0",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
@@ -18,22 +18,20 @@
"dependencies": {
"glob": "~3.2.1",
"lru-cache": "2",
- "normalize-package-data": "~0.1.2",
- "npmlog": "0",
+ "normalize-package-data": "~0.2",
"graceful-fs": "~1.2"
},
"devDependencies": {
"tap": "~0.2.5"
},
"optionalDependencies": {
- "npmlog": "0",
"graceful-fs": "~1.2"
},
- "readme": "# read-package-json\n\nThis is the thing that npm uses to read package.json files. It\nvalidates some stuff, and loads some default things.\n\nIt keeps a cache of the files you've read, so that you don't end\nup reading the same package.json file multiple times.\n\nNote that if you just want to see what's literally in the package.json\nfile, you can usually do `var data = require('some-module/package.json')`.\n\nThis module is basically only needed by npm, but it's handy to see what\nnpm will see when it looks at your package.\n\n## Usage\n\n```javascript\nvar readJson = require('read-package-json')\n\nreadJson('/path/to/package.json', function (er, data) {\n if (er) {\n console.error(\"There was an error reading the file\")\n return\n }\n\n console.error('the package data is', data)\n}\n```\n\n## readJson(file, cb)\n\n* `file` {String} The path to the package.json file\n* `cb` {Function}\n\nReads the JSON file and does the things.\n\n## `package.json` Fields\n\nSee `man 5 package.json` or `npm help json`.\n\n## readJson.log\n\nBy default this is a reference to the `npmlog` module. But if that\nmodule can't be found, then it'll be set to just a dummy thing that does\nnothing.\n\nReplace with your own `{log,warn,error}` object for fun loggy time.\n\n## readJson.extras(file, data, cb)\n\nRun all the extra stuff relative to the file, with the parsed data.\n\nModifies the data as it does stuff. Calls the cb when it's done.\n\n## readJson.extraSet = [fn, fn, ...]\n\nArray of functions that are called by `extras`. Each one receives the\narguments `fn(file, data, cb)` and is expected to call `cb(er, data)`\nwhen done or when an error occurs.\n\nOrder is indeterminate, so each function should be completely\nindependent.\n\nMix and match!\n\n## readJson.cache\n\nThe `lru-cache` object that readJson uses to not read the same file over\nand over again. See\n[lru-cache](https://github.com/isaacs/node-lru-cache) for details.\n\n## Other Relevant Files Besides `package.json`\n\nSome other files have an effect on the resulting data object, in the\nfollowing ways:\n\n### `README?(.*)`\n\nIf there is a `README` or `README.*` file present, then npm will attach\na `readme` field to the data with the contents of this file.\n\nOwing to the fact that roughly 100% of existing node modules have\nMarkdown README files, it will generally be assumed to be Markdown,\nregardless of the extension. Please plan accordingly.\n\n### `server.js`\n\nIf there is a `server.js` file, and there is not already a\n`scripts.start` field, then `scripts.start` will be set to `node\nserver.js`.\n\n### `AUTHORS`\n\nIf there is not already a `contributors` field, then the `contributors`\nfield will be set to the contents of the `AUTHORS` file, split by lines,\nand parsed.\n\n### `bindings.gyp`\n\nIf a bindings.gyp file exists, and there is not already a\n`scripts.install` field, then the `scripts.install` field will be set to\n`node-gyp rebuild`.\n\n### `wscript`\n\nIf a wscript file exists, and there is not already a `scripts.install`\nfield, then the `scripts.install` field will be set to `node-waf clean ;\nnode-waf configure build`.\n\nNote that the `bindings.gyp` file supercedes this, since node-waf has\nbeen deprecated in favor of node-gyp.\n\n### `index.js`\n\nIf the json file does not exist, but there is a `index.js` file\npresent instead, and that file has a package comment, then it will try\nto parse the package comment, and use that as the data instead.\n\nA package comment looks like this:\n\n```javascript\n/**package\n * { \"name\": \"my-bare-module\"\n * , \"version\": \"1.2.3\"\n * , \"description\": \"etc....\" }\n **/\n\n// or...\n\n/**package\n{ \"name\": \"my-bare-module\"\n, \"version\": \"1.2.3\"\n, \"description\": \"etc....\" }\n**/\n```\n\nThe important thing is that it starts with `/**package`, and ends with\n`**/`. If the package.json file exists, then the index.js is not\nparsed.\n\n### `{directories.man}/*.[0-9]`\n\nIf there is not already a `man` field defined as an array of files or a\nsingle file, and\nthere is a `directories.man` field defined, then that directory will\nbe searched for manpages.\n\nAny valid manpages found in that directory will be assigned to the `man`\narray, and installed in the appropriate man directory at package install\ntime, when installed globally on a Unix system.\n\n### `{directories.bin}/*`\n\nIf there is not already a `bin` field defined as a string filename or a\nhash of `<name> : <filename>` pairs, then the `directories.bin`\ndirectory will be searched and all the files within it will be linked as\nexecutables at install time.\n\nWhen installing locally, npm links bins into `node_modules/.bin`, which\nis in the `PATH` environ when npm runs scripts. When\ninstalling globally, they are linked into `{prefix}/bin`, which is\npresumably in the `PATH` environment variable.\n",
+ "readme": "# read-package-json\n\nThis is the thing that npm uses to read package.json files. It\nvalidates some stuff, and loads some default things.\n\nIt keeps a cache of the files you've read, so that you don't end\nup reading the same package.json file multiple times.\n\nNote that if you just want to see what's literally in the package.json\nfile, you can usually do `var data = require('some-module/package.json')`.\n\nThis module is basically only needed by npm, but it's handy to see what\nnpm will see when it looks at your package.\n\n## Usage\n\n```javascript\nvar readJson = require('read-package-json')\n\n// readJson(filename, [logFunction=noop], [strict=false], cb)\nreadJson('/path/to/package.json', console.error, false, function (er, data) {\n if (er) {\n console.error(\"There was an error reading the file\")\n return\n }\n\n console.error('the package data is', data)\n}\n```\n\n## readJson(file, [logFn = noop], [strict = false], cb)\n\n* `file` {String} The path to the package.json file\n* `logFn` {Function} Function to handle logging. Defaults to a noop.\n* `strict` {Boolean} True to enforce SemVer 2.0 version strings, and\n other strict requirements.\n* `cb` {Function} Gets called with `(er, data)`, as is The Node Way.\n\nReads the JSON file and does the things.\n\n## `package.json` Fields\n\nSee `man 5 package.json` or `npm help json`.\n\n## readJson.log\n\nBy default this is a reference to the `npmlog` module. But if that\nmodule can't be found, then it'll be set to just a dummy thing that does\nnothing.\n\nReplace with your own `{log,warn,error}` object for fun loggy time.\n\n## readJson.extras(file, data, cb)\n\nRun all the extra stuff relative to the file, with the parsed data.\n\nModifies the data as it does stuff. Calls the cb when it's done.\n\n## readJson.extraSet = [fn, fn, ...]\n\nArray of functions that are called by `extras`. Each one receives the\narguments `fn(file, data, cb)` and is expected to call `cb(er, data)`\nwhen done or when an error occurs.\n\nOrder is indeterminate, so each function should be completely\nindependent.\n\nMix and match!\n\n## readJson.cache\n\nThe `lru-cache` object that readJson uses to not read the same file over\nand over again. See\n[lru-cache](https://github.com/isaacs/node-lru-cache) for details.\n\n## Other Relevant Files Besides `package.json`\n\nSome other files have an effect on the resulting data object, in the\nfollowing ways:\n\n### `README?(.*)`\n\nIf there is a `README` or `README.*` file present, then npm will attach\na `readme` field to the data with the contents of this file.\n\nOwing to the fact that roughly 100% of existing node modules have\nMarkdown README files, it will generally be assumed to be Markdown,\nregardless of the extension. Please plan accordingly.\n\n### `server.js`\n\nIf there is a `server.js` file, and there is not already a\n`scripts.start` field, then `scripts.start` will be set to `node\nserver.js`.\n\n### `AUTHORS`\n\nIf there is not already a `contributors` field, then the `contributors`\nfield will be set to the contents of the `AUTHORS` file, split by lines,\nand parsed.\n\n### `bindings.gyp`\n\nIf a bindings.gyp file exists, and there is not already a\n`scripts.install` field, then the `scripts.install` field will be set to\n`node-gyp rebuild`.\n\n### `wscript`\n\nIf a wscript file exists, and there is not already a `scripts.install`\nfield, then the `scripts.install` field will be set to `node-waf clean ;\nnode-waf configure build`.\n\nNote that the `bindings.gyp` file supercedes this, since node-waf has\nbeen deprecated in favor of node-gyp.\n\n### `index.js`\n\nIf the json file does not exist, but there is a `index.js` file\npresent instead, and that file has a package comment, then it will try\nto parse the package comment, and use that as the data instead.\n\nA package comment looks like this:\n\n```javascript\n/**package\n * { \"name\": \"my-bare-module\"\n * , \"version\": \"1.2.3\"\n * , \"description\": \"etc....\" }\n **/\n\n// or...\n\n/**package\n{ \"name\": \"my-bare-module\"\n, \"version\": \"1.2.3\"\n, \"description\": \"etc....\" }\n**/\n```\n\nThe important thing is that it starts with `/**package`, and ends with\n`**/`. If the package.json file exists, then the index.js is not\nparsed.\n\n### `{directories.man}/*.[0-9]`\n\nIf there is not already a `man` field defined as an array of files or a\nsingle file, and\nthere is a `directories.man` field defined, then that directory will\nbe searched for manpages.\n\nAny valid manpages found in that directory will be assigned to the `man`\narray, and installed in the appropriate man directory at package install\ntime, when installed globally on a Unix system.\n\n### `{directories.bin}/*`\n\nIf there is not already a `bin` field defined as a string filename or a\nhash of `<name> : <filename>` pairs, then the `directories.bin`\ndirectory will be searched and all the files within it will be linked as\nexecutables at install time.\n\nWhen installing locally, npm links bins into `node_modules/.bin`, which\nis in the `PATH` environ when npm runs scripts. When\ninstalling globally, they are linked into `{prefix}/bin`, which is\npresumably in the `PATH` environment variable.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/isaacs/read-package-json/issues"
},
- "_id": "read-package-json@0.4.1",
- "_from": "read-package-json@~0.4.1"
+ "_id": "read-package-json@1.1.0",
+ "_from": "read-package-json@1"
}
diff --git a/node_modules/read-package-json/read-json.js b/node_modules/read-package-json/read-json.js
index acb128680..d9a4610d9 100644
--- a/node_modules/read-package-json/read-json.js
+++ b/node_modules/read-package-json/read-json.js
@@ -1,17 +1,6 @@
// vim: set softtabstop=16 shiftwidth=16:
try {
- readJson.log = require("npmlog")
-} catch (er) {
- readJson.log = {
- info: function () {},
- verbose: function () {},
- warn: function () {}
- }
-}
-
-
-try {
var fs = require("graceful-fs")
} catch (er) {
var fs = require("fs")
@@ -40,25 +29,33 @@ readJson.extraSet = [
var typoWarned = {}
-function readJson (file, cb) {
+function readJson (file, log_, strict_, cb_) {
+ var log, strict, cb
+ for (var i = 1; i < arguments.length - 1; i++) {
+ if (typeof arguments[i] === 'boolean')
+ strict = arguments[i]
+ else if (typeof arguments[i] === 'function')
+ log = arguments[i]
+ }
+ if (!log) log = function () {};
+ cb = arguments[ arguments.length - 1 ]
+
var c = readJson.cache.get(file)
if (c) {
- readJson.log.verbose("from cache", file)
cb = cb.bind(null, null, c)
return process.nextTick(cb);
}
- readJson.log.verbose("read json", file)
cb = (function (orig) { return function (er, data) {
if (data) readJson.cache.set(file, data);
return orig(er, data)
} })(cb)
- readJson_(file, cb)
+ readJson_(file, log, strict, cb)
}
-function readJson_ (file, cb) {
+function readJson_ (file, log, strict, cb) {
fs.readFile(file, "utf8", function (er, d) {
- parseJson(file, er, d, cb)
+ parseJson(file, er, d, log, strict, cb)
})
}
@@ -74,9 +71,9 @@ function stripBOM(content) {
}
-function parseJson (file, er, d, cb) {
+function parseJson (file, er, d, log, strict, cb) {
if (er && er.code === "ENOENT") {
- indexjs(file, er, cb)
+ indexjs(file, er, log, strict, cb)
return
}
if (er) return cb(er);
@@ -86,11 +83,11 @@ function parseJson (file, er, d, cb) {
d = parseIndex(d)
if (!d) return cb(parseError(er, file));
}
- extras(file, d, cb)
+ extras(file, d, log, strict, cb)
}
-function indexjs (file, er, cb) {
+function indexjs (file, er, log, strict, cb) {
if (path.basename(file) === "index.js") {
return cb(er);
}
@@ -99,13 +96,21 @@ function indexjs (file, er, cb) {
if (er2) return cb(er);
d = parseIndex(d)
if (!d) return cb(er);
- extras(file, d, cb)
+ extras(file, d, log, strict, cb)
})
}
readJson.extras = extras
-function extras (file, data, cb) {
+function extras (file, data, log_, strict_, cb_) {
+ var log, strict, cb
+ for (var i = 2; i < arguments.length - 1; i++) {
+ if (typeof arguments[i] === 'boolean')
+ strict = arguments[i]
+ else if (typeof arguments[i] === 'function')
+ log = arguments[i]
+ }
+ cb = arguments[i]
var set = readJson.extraSet
var n = set.length
var errState = null
@@ -115,7 +120,8 @@ function extras (file, data, cb) {
function then(er) {
if (errState) return;
if (er) return cb(errState = er);
- if (--n === 0) final(file, data, cb);
+ if (--n > 0) return;
+ final(file, data, log, strict, cb);
}
}
@@ -294,14 +300,14 @@ function githead_ (file, data, dir, head, cb) {
})
}
-function final (file, data, cb) {
+function final (file, data, log, strict, cb) {
var pId = makePackageId(data)
function warn(msg) {
if (typoWarned[pId]) return;
- readJson.log.warn("package.json", pId, msg)
+ if (log) log("package.json", pId, msg);
}
try {
- normalizeData(data, warn)
+ normalizeData(data, warn, strict)
}
catch (error) {
return cb(error)