Skip to content

Commit

Permalink
fix: #125 - remove debug dependency from lockfile-lint-api, remove 'u…
Browse files Browse the repository at this point in the history
…rl' dependency, bump engine to v10 (#127)

BREAKING CHANGE: Dropped support for Node.js 8.x - now supported versions start at Node.js 10.x
  • Loading branch information
naugtur authored Jun 11, 2022
1 parent 18c6ae0 commit b4a8143
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 15 deletions.
3 changes: 1 addition & 2 deletions packages/lockfile-lint-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Lint an npm or yarn lockfile to analyze and detect issues",
"main": "index.js",
"engines": {
"node": ">=8.0.0"
"node": ">=10.0.0"
},
"scripts": {
"lint": "eslint .",
Expand Down Expand Up @@ -49,7 +49,6 @@
},
"dependencies": {
"@yarnpkg/parsers": "^3.0.0-rc.6",
"debug": "^4.1.1",
"object-hash": "^2.0.1"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/lockfile-lint-api/src/validators/ValidateHost.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict'

const {URL} = require('url')
const debug = require('debug')('lockfile-lint-api')
const {REGISTRY} = require('../common/constants')

const noop = () => {}
module.exports = class ValidateHost {
constructor ({packages} = {}) {
constructor ({packages, debug = noop} = {}) {
if (typeof packages !== 'object') {
throw new Error('expecting an object passed to validator constructor')
}

this.packages = packages
this.debug = debug
}

validate (hosts, options) {
Expand Down Expand Up @@ -41,7 +41,7 @@ module.exports = class ValidateHost {
hostValue = parsedHost.host
}
} catch (error) {
debug(`failed parsing a URL object from given host value so using as is: ${host}`)
this.debug(`failed parsing a URL object from given host value so using as is: ${host}`)
}

return hostValue
Expand All @@ -50,7 +50,7 @@ module.exports = class ValidateHost {
const isPassing = allowedHosts.includes(packageResolvedURL.host)
if (!isPassing) {
if (!packageResolvedURL.host && options && options.emptyHostname) {
debug(`detected empty hostname but allowing because emptyHostname is not false`)
this.debug(`detected empty hostname but allowing because emptyHostname is not false`)
} else {
validationResult.errors.push({
message: `detected invalid host(s) for package: ${packageName}\n expected: ${allowedHosts}\n actual: ${
Expand Down
2 changes: 0 additions & 2 deletions packages/lockfile-lint-api/src/validators/ValidateHttps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const {URL} = require('url')

const HTTPS_PROTOCOL = 'https:'

module.exports = class ValidateHttps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const {URL} = require('url')

module.exports = class ValidatePackageNames {
constructor ({packages} = {}) {
if (typeof packages !== 'object') {
Expand Down
2 changes: 0 additions & 2 deletions packages/lockfile-lint-api/src/validators/ValidateScheme.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const {URL} = require('url')

module.exports = class ValidateProtocol {
constructor ({packages} = {}) {
if (typeof packages !== 'object') {
Expand Down
2 changes: 1 addition & 1 deletion packages/lockfile-lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lockfile-lint": "./bin/lockfile-lint.js"
},
"engines": {
"node": ">=8.0.0"
"node": ">=10.0.0"
},
"scripts": {
"lint": "eslint .",
Expand Down
2 changes: 1 addition & 1 deletion packages/lockfile-lint/src/validators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function ValidateHostManager ({path, type, validatorValues, validatorOptions}) {

const parser = new ParseLockfile(options)
const lockfile = parser.parseSync()
const validator = new ValidateHost({packages: lockfile.object})
const validator = new ValidateHost({packages: lockfile.object, debug: require('debug')('lockfile-lint')})
const validationResult = validator.validate(validatorValues, validatorOptions)

// Check if some of the errors are for allowed URLs and filter those out
Expand Down

0 comments on commit b4a8143

Please sign in to comment.