Socket
Socket
Sign inDemoInstall

normalize-package-data

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-package-data - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

lib/make_warning.js

66

lib/fixer.js

@@ -9,4 +9,2 @@ var semver = require("semver")

var githubUserRepo = require("github-url-from-username-repo")
var warningMessages = require('./warning_messages.json')
var format = require('util').format

@@ -19,6 +17,6 @@ var fixer = module.exports = {

if (data.repositories) {
this.warn(warningMessages.repositories);
this.warn("repositories");
data.repository = data.repositories[0]
}
if (!data.repository) return this.warn(warningMessages.missingRepository)
if (!data.repository) return this.warn("missingRepository")
if (typeof data.repository === "string") {

@@ -42,3 +40,3 @@ data.repository = {

if (r.match(/github.com\/[^\/]+\/[^\/]+\.git\.git$/)) {
this.warn(format(warningMessages.brokenGitUrl, r))
this.warn("brokenGitUrl", r)
}

@@ -50,3 +48,3 @@ }

if (data.hasOwnProperty(d)) {
this.warn(makeTypoWarning(d, typos.topLevel[d]))
this.warn("typo", d, typos.topLevel[d])
}

@@ -59,3 +57,3 @@ }, this)

if (typeof data.scripts !== "object") {
this.warn(warningMessages.nonObjectScripts)
this.warn("nonObjectScripts")
delete data.scripts

@@ -65,6 +63,6 @@ }

if (typeof data.scripts[k] !== "string") {
this.warn(warningMessages.nonStringScript)
this.warn("nonStringScript")
delete data.scripts[k]
} else if (typos.script[k]) {
this.warn(makeTypoWarning(k, typos.script[k], "scripts"))
this.warn("typo", k, typos.script[k], "scripts")
}

@@ -77,3 +75,3 @@ }, this)

if (files && !Array.isArray(files)) {
this.warn(warningMessages.nonArrayFiles)
this.warn("nonArrayFiles")
delete data.files

@@ -83,3 +81,3 @@ } else if (data.files) {

if (!file || typeof file !== "string") {
this.warn(format(warningMessages.invalidFilename, file))
this.warn("invalidFilename", file)
return false

@@ -116,3 +114,3 @@ } else {

if (data[bd] && !Array.isArray(data[bd])) {
this.warn(warningMessages.nonArrayBundleDependencies)
this.warn("nonArrayBundleDependencies")
delete data[bd]

@@ -122,3 +120,3 @@ } else if (data[bd]) {

if (!bd || typeof bd !== 'string') {
this.warn(format(warningMessages.nonStringBundleDependency, bd))
this.warn("nonStringBundleDependency", bd)
return false

@@ -141,3 +139,3 @@ } else {

if (!data[deps] || typeof data[deps] !== "object") {
this.warn(format(warningMessages.nonObjectDependencies, deps))
this.warn("nonObjectDependencies", deps)
delete data[deps]

@@ -149,3 +147,3 @@ return

if (typeof r !== 'string') {
this.warn(format(warningMessages.nonStringDependency, d, JSON.stringify(r)))
this.warn("nonStringDependency", d, JSON.stringify(r))
delete data[deps][d]

@@ -164,3 +162,3 @@ }

if (data.modules) {
this.warn(warningMessages.deprecatedModules)
this.warn("deprecatedModules")
delete data.modules

@@ -176,7 +174,7 @@ }

delete data.keywords
this.warn(warningMessages.nonArrayKeywords)
this.warn("nonArrayKeywords")
} else if (data.keywords) {
data.keywords = data.keywords.filter(function(kw) {
if (typeof kw !== "string" || !kw) {
this.warn(warningMessages.nonStringKeyword);
this.warn("nonStringKeyword");
return false

@@ -222,3 +220,3 @@ } else {

if (coreModuleNames.indexOf(data.name) !== -1)
this.warn(format(warningMessages.conflictingName, data.name))
this.warn("conflictingName", data.name)
}

@@ -229,3 +227,3 @@

if (data.description && typeof data.description !== 'string') {
this.warn(warningMessages.nonStringDescription)
this.warn("nonStringDescription")
delete data.description

@@ -236,3 +234,3 @@ }

if(data.description === undefined) delete data.description;
if (!data.description) this.warn(warningMessages.missingDescription)
if (!data.description) this.warn("missingDescription")
}

@@ -242,3 +240,3 @@

if (!data.readme) {
this.warn(warningMessages.missingReadme)
this.warn("missingReadme")
data.readme = "ERROR: No README data found!"

@@ -266,3 +264,3 @@ }

else
this.warn(warningMessages.nonEmailUrlBugsString)
this.warn("nonEmailUrlBugsString")
}

@@ -277,3 +275,3 @@ else {

else
this.warn(warningMessages.nonUrlBugsUrlField)
this.warn("nonUrlBugsUrlField")
}

@@ -284,3 +282,3 @@ if(oldBugs.email) {

else
this.warn(warningMessages.nonEmailBugsEmailField)
this.warn("nonEmailBugsEmailField")
}

@@ -290,3 +288,3 @@ }

delete data.bugs
this.warn(warningMessages.emptyNormalizedBugs)
this.warn("emptyNormalizedBugs")
}

@@ -307,7 +305,7 @@ }

if(typeof data.homepage !== "string") {
this.warn(warningMessages.nonUrlHomepage)
this.warn("nonUrlHomepage")
return delete data.homepage
}
if(!url.parse(data.homepage).protocol) {
this.warn(warningMessages.missingProtocolHomepage)
this.warn("missingProtocolHomepage")
data.homepage = "http://" + data.homepage

@@ -376,3 +374,3 @@ }

if (!Array.isArray(deps)) return deps
warn(format(warningMessages.deprecatedArrayDependencies, type))
warn("deprecatedArrayDependencies", type)
var o = {}

@@ -403,3 +401,3 @@ deps.filter(function (d) {

if (typos.bugs[k]) {
warn(makeTypoWarning(k, typos.bugs[k], "bugs"))
warn("typo", k, typos.bugs[k], "bugs")
bugs[typos.bugs[k]] = bugs[k]

@@ -409,10 +407,2 @@ delete bugs[k]

})
}
function makeTypoWarning (providedName, probableName, field) {
if (field) {
providedName = field + "['" + providedName + "']"
probableName = field + "['" + probableName + "']"
}
return format(warningMessages.typo, providedName, probableName)
}
module.exports = normalize
var fixer = require("./fixer")
var makeWarning = require("./make_warning")

@@ -27,3 +28,3 @@ var fieldsToFix = ['name','version','description','repository','modules','scripts'

}
fixer.warn = warn
fixer.warn = function() { warn(makeWarning.apply(null, arguments)) }
thingsToFix.forEach(function(thingName) {

@@ -30,0 +31,0 @@ fixer["fix" + ucFirst(thingName)](data, strict)

{
"name": "normalize-package-data",
"version": "0.2.12",
"version": "0.2.13",
"author": "Meryn Stol <merynstol@gmail.com>",

@@ -15,5 +15,5 @@ "description": "Normalizes data that can be found in package.json files.",

"dependencies": {
"semver": "2",
"github-url-from-git": "~1.1.1",
"github-url-from-username-repo": "0.0.2"
"github-url-from-username-repo": "^0.1.0",
"semver": "2"
},

@@ -20,0 +20,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc