Comparing version 0.1.2 to 0.1.3
@@ -37,4 +37,3 @@ 'use strict'; | ||
for (const f in files) { | ||
loadedRules = loadedRules.concat(deepMergeRules(files[f])) | ||
console.log(loadedRules) | ||
loadedRules = loadedRules.concat(deepMergeRules(files[f])); | ||
} | ||
@@ -48,3 +47,3 @@ } | ||
if ((rule.object[0] === '*') || (rule.object.indexOf(objectName)>=0)) { | ||
const lintRule = rule; | ||
options.lintRule = rule; | ||
if (rule.skip && options[rule.skip]) { | ||
@@ -108,3 +107,2 @@ continue; | ||
const { value, property } = rule.maxLength; | ||
console.log(object[property]) | ||
if (object[property] && (typeof object[property] === 'string')) { | ||
@@ -111,0 +109,0 @@ object.should.have.property(property).with.lengthOf(value); |
51
lint.js
@@ -14,6 +14,12 @@ #!/usr/bin/env node | ||
const red = process.env.NODE_DISABLE_COLORS ? '' : '\x1b[31m'; | ||
const green = process.env.NODE_DISABLE_COLORS ? '' : '\x1b[32m'; | ||
const yellow = process.env.NODE_DISABLE_COLORS ? '' : '\x1b[33;1m'; | ||
const normal = process.env.NODE_DISABLE_COLORS ? '' : '\x1b[0m'; | ||
const colors = process.env.NODE_DISABLE_COLORS ? {} : { | ||
red: '\x1b[31m', | ||
green: '\x1b[32m', | ||
yellow: '\x1b[33m', | ||
blue: '\x1b[34m', | ||
magenta: '\x1b[35m', | ||
cyan: '\x1b[36m', | ||
white: '\x1b[37m', | ||
reset: '\x1b[0m', | ||
}; | ||
@@ -29,21 +35,30 @@ var pass = 0; | ||
validator.validate(options.openapi, options, function(err, options) { | ||
if (err) { | ||
console.log(red + options.context.pop() + '\n' + err.message); | ||
if (err.stack && err.name !== 'AssertionError') { | ||
console.log(err.stack); | ||
} | ||
if (options.lintRule && options.lintRule.description !== err.message) { | ||
console.warn(options.lintRule.description); | ||
} | ||
options.valid = !!options.expectFailure; | ||
process.exitCode = 1; | ||
return; | ||
if (!err) { | ||
console.log('File is valid') | ||
process.exitCode = 0; | ||
return; | ||
} | ||
console.log('File is valid') | ||
process.exitCode = 0; | ||
formatLinterError(err, options.context, options.lintRule); | ||
options.valid = !!options.expectFailure; | ||
process.exitCode = 1; | ||
}); | ||
}; | ||
const formatLinterError = (err, context, rule) => { | ||
const pointer = context.pop(); | ||
const message = err.message; | ||
const output = ` | ||
${colors['yellow'] + pointer} ${colors['cyan']} R: ${rule.name} ${colors['white']} D: ${rule.description} | ||
${colors['reset'] + message} | ||
` | ||
console.log(output); | ||
if (err.stack && err.name !== 'AssertionError') { | ||
console.log(colors['red'] + err.stack); | ||
} | ||
} | ||
const resolveSchema = (str, callback) => { | ||
@@ -50,0 +65,0 @@ options.openapi = yaml.safeLoad(str,{json:true}); |
{ | ||
"name": "speccy", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Your friendly OpenAPI v3.0 #WellActually CLI assistant.", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -15,3 +15,3 @@ { | ||
"enabled": true, | ||
"description": "summary should be short, make the description longer if you need to write more", | ||
"description": "summary should be short (description can be long)", | ||
"maxLength": { "property": "summary", "value": 20 } | ||
@@ -18,0 +18,0 @@ } |
@@ -15,11 +15,11 @@ { | ||
{ | ||
"url": "http://localhost:5000/", | ||
"url": "http://localhost:5000", | ||
"description": "Development server" | ||
}, | ||
{ | ||
"url": "https://rooms-staging.wework.com/", | ||
"url": "https://rooms-staging.wework.com", | ||
"description": "Staging server" | ||
}, | ||
{ | ||
"url": "https://rooms.wework.com/", | ||
"url": "https://rooms.wework.com", | ||
"description": "Production server" | ||
@@ -26,0 +26,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5068
11
191804