@stoplight/spectral
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -13,2 +13,3 @@ import { Command, flags as flagHelpers } from '@oclif/command'; | ||
verbose: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>; | ||
config: flagHelpers.IOptionFlag<string | undefined>; | ||
ruleset: flagHelpers.IOptionFlag<string[]>; | ||
@@ -15,0 +16,0 @@ }; |
@@ -7,4 +7,6 @@ "use strict"; | ||
const fs_1 = require("fs"); | ||
const lodash_1 = require("lodash"); | ||
const path_1 = require("path"); | ||
const util_1 = require("util"); | ||
const configLoader_1 = require("../../config/configLoader"); | ||
const formatters_1 = require("../../formatters"); | ||
@@ -16,2 +18,3 @@ const reader_1 = require("../../fs/reader"); | ||
const spectral_1 = require("../../spectral"); | ||
const config_1 = require("../../types/config"); | ||
const writeFileAsync = util_1.promisify(fs_1.writeFile); | ||
@@ -22,3 +25,15 @@ class Lint extends command_1.Command { | ||
const { args, flags } = this.parse(Lint); | ||
const { ruleset } = flags; | ||
const { config: configFileFlag } = flags; | ||
let config = mergeConfig(configLoader_1.createEmptyConfig(), flags); | ||
const configFile = configFileFlag || configLoader_1.getDefaultConfigFile(process.cwd()) || null; | ||
if (configFile) { | ||
try { | ||
const loadedConfig = yield configLoader_1.load(configFile, config_1.ConfigCommand.LINT); | ||
config = mergeConfig(loadedConfig, flags); | ||
} | ||
catch (ex) { | ||
this.error(`Cannot load provided config file. ${ex.message}.`); | ||
} | ||
} | ||
const { ruleset } = config; | ||
let rules; | ||
@@ -35,3 +50,3 @@ if (ruleset) { | ||
try { | ||
yield lint(args.source, flags, this, rules); | ||
yield lint(args.source, config, this, rules); | ||
} | ||
@@ -58,3 +73,2 @@ catch (ex) { | ||
char: 'e', | ||
default: 'utf8', | ||
description: 'text encoding to use', | ||
@@ -64,3 +78,2 @@ }), | ||
char: 'f', | ||
default: 'stylish', | ||
description: 'formatter to use for outputting results', | ||
@@ -81,2 +94,6 @@ options: ['json', 'stylish'], | ||
}), | ||
config: command_1.flags.string({ | ||
char: 'c', | ||
description: 'path to a config file', | ||
}), | ||
ruleset: command_1.flags.string({ | ||
@@ -161,2 +178,12 @@ char: 'r', | ||
exports.writeOutput = writeOutput; | ||
function mergeConfig(config, flags) { | ||
return Object.assign({}, config.lint, lodash_1.omitBy({ | ||
encoding: flags.encoding, | ||
format: flags.format, | ||
output: flags.output, | ||
maxResults: flags.maxResults, | ||
verbose: flags.verbose, | ||
ruleset: flags.ruleset, | ||
}, lodash_1.isNil)); | ||
} | ||
//# sourceMappingURL=lint.js.map |
@@ -1,1 +0,1 @@ | ||
{"version":"2.1.0","commands":{"lint":{"id":"lint","description":"lint a JSON/YAML document from a file or URL","pluginName":"@stoplight/spectral","pluginType":"core","aliases":[],"examples":["$ spectral lint .openapi.yaml\nlinting ./openapi.yaml\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"encoding":{"name":"encoding","type":"option","char":"e","description":"text encoding to use","default":"utf8"},"format":{"name":"format","type":"option","char":"f","description":"formatter to use for outputting results","options":["json","stylish"],"default":"stylish"},"output":{"name":"output","type":"option","char":"o","description":"output to a file instead of stdout"},"maxResults":{"name":"maxResults","type":"option","char":"m","description":"[default: all] maximum results to show"},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"increase verbosity","allowNo":false},"ruleset":{"name":"ruleset","type":"option","char":"r","description":"path to a ruleset file (supports remote files)"}},"args":[{"name":"source"}]}}} | ||
{"version":"2.1.1","commands":{"lint":{"id":"lint","description":"lint a JSON/YAML document from a file or URL","pluginName":"@stoplight/spectral","pluginType":"core","aliases":[],"examples":["$ spectral lint .openapi.yaml\nlinting ./openapi.yaml\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"encoding":{"name":"encoding","type":"option","char":"e","description":"text encoding to use"},"format":{"name":"format","type":"option","char":"f","description":"formatter to use for outputting results","options":["json","stylish"]},"output":{"name":"output","type":"option","char":"o","description":"output to a file instead of stdout"},"maxResults":{"name":"maxResults","type":"option","char":"m","description":"[default: all] maximum results to show"},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"increase verbosity","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"path to a config file"},"ruleset":{"name":"ruleset","type":"option","char":"r","description":"path to a ruleset file (supports remote files)"}},"args":[{"name":"source"}]}}} |
{ | ||
"name": "@stoplight/spectral", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A flexible object linter with out of the box support for OpenAPI v2 and v3.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
280872
133
5888
3