barnard59-pipeline-validation
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -0,1 +1,5 @@ | ||
# `v0.2.0` | ||
* Add an experimental `manifest.ttl` checker: `barnard59-validate -m manifest.ttl -v` | ||
# `v0.1.1` | ||
@@ -2,0 +6,0 @@ |
35
cli.js
@@ -8,2 +8,3 @@ #!/usr/bin/env node | ||
const { removeFilePart } = require('./lib/utils') | ||
const validate = require('./lib/manifest') | ||
@@ -13,3 +14,3 @@ const program = new Command() | ||
async function main (file, options) { | ||
async function validatePipeline (file, options) { | ||
const pipelineFile = path.resolve(file) | ||
@@ -48,5 +49,28 @@ const pipelineDir = removeFilePart(pipelineFile) | ||
async function validateManifest (file, options) { | ||
const checks = new ChecksCollection() | ||
try { | ||
await validate({ file, checks }) | ||
} | ||
catch (err) { | ||
if (options.debug) { | ||
console.error(err) | ||
} | ||
} | ||
checks.print(options.levels) | ||
if (!process.stdout.isTTY) { | ||
console.log(checks.filterToJSON(options.levels)) | ||
} | ||
if (checks.countIssues(options.strict)) { | ||
process.exit(-1) | ||
} | ||
} | ||
program | ||
.arguments('<pipelineFile>') | ||
.option('-d, --debug', 'Shows debug information', false) | ||
.option('-m, --manifest', 'Validate a manifest.ttl instead of a pipeline', false) | ||
.option('-p, --pipeline <pipelineIRI>', 'Pipeline IRI', null) | ||
@@ -56,3 +80,3 @@ .option('-q, --quiet', 'Report errors only', false) | ||
.option('-v, --verbose', 'Include successful validation checks in output', false) | ||
.action((pipelineFile, options) => { | ||
.action(async (file, options) => { | ||
options.levels = ['error'] | ||
@@ -68,4 +92,9 @@ if (!options.quiet) { | ||
} | ||
main(pipelineFile, options) | ||
if (!options.manifest) { | ||
validatePipeline(file, options) | ||
} | ||
else { | ||
await validateManifest(file, options) | ||
} | ||
}) | ||
program.parse() |
@@ -6,7 +6,9 @@ const codelink = require('./codelink') | ||
const operationHasOperationProperty = require('./operationHasOperationProperty') | ||
const operationIsExported = require('./operationIsExported') | ||
const operationIsImportable = require('./operationIsImportable') | ||
const operationPropertiesExist = require('./operationPropertiesExist') | ||
const pipelinePropertiesExist = require('./pipelinePropertiesExist') | ||
const pipelinePropertiesMatchFirstFlex = require('./pipelinePropertiesMatchFirstFlex') | ||
const pipelinePropertiesMatchFirstStrict = require('./pipelinePropertiesMatchFirstStrict') | ||
const pipelinePropertiesMatchLastFlex = require('./pipelinePropertiesMatchLastFlex') | ||
const pipelinePropertiesMatchFirstStrict = require('./pipelinePropertiesMatchFirstStrict') | ||
const pipelinePropertiesMatchLastStrict = require('./pipelinePropertiesMatchLastStrict') | ||
@@ -25,7 +27,9 @@ const previousOperationHasMetadata = require('./previousOperationHasMetadata') | ||
operationHasOperationProperty, | ||
operationIsExported, | ||
operationIsImportable, | ||
operationPropertiesExist, | ||
pipelinePropertiesExist, | ||
pipelinePropertiesMatchFirstFlex, | ||
pipelinePropertiesMatchFirstStrict, | ||
pipelinePropertiesMatchLastFlex, | ||
pipelinePropertiesMatchFirstStrict, | ||
pipelinePropertiesMatchLastStrict, | ||
@@ -32,0 +36,0 @@ previousOperationHasMetadata, |
{ | ||
"name": "barnard59-pipeline-validation", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "cli.js", |
@@ -69,2 +69,14 @@ [ | ||
{ | ||
"ruleId": 14, | ||
"ruleDescription": "Operation defined in manifest can be imported", | ||
"messageSuccess": "${filename} can be imported for operation ${op}", | ||
"messageFailure": "Cannot import ${filename} for operation ${op}" | ||
}, | ||
{ | ||
"ruleId": 15, | ||
"ruleDescription": "Operation defined in manifest has a corresponding export", | ||
"messageSuccess": "File ${filename} exports '${method}' for operation ${op}", | ||
"messageFailure": "File ${filename} does not export ${method} for operation ${op}" | ||
}, | ||
{ | ||
"ruleId": 51, | ||
@@ -71,0 +83,0 @@ "ruleDescription": "Pipeline should have the same type if its first stream is Writable(ObjectMode)", |
@@ -78,2 +78,16 @@ const { describe, it } = require('mocha') | ||
}) | ||
it('should validate manifests', () => { | ||
const exec = chaiExec('-m ./test/fixtures/manifest-good.ttl') | ||
const infos = JSON.parse(exec.stdout).filter(issue => issue.level === 'info').length | ||
assert.strictEqual(infos, 0) | ||
const verbose = chaiExec('-m ./test/fixtures/manifest-good.ttl -v') | ||
const verboseInfos = JSON.parse(verbose.stdout).filter(issue => issue.level === 'info').length | ||
assert.ok(verboseInfos > 0) | ||
const error = chaiExec('-m ./test/fixtures/manifest-bad.ttl') | ||
const errors = JSON.parse(error.stdout).filter(issue => issue.level === 'error').length | ||
assert.strictEqual(errors, 2) | ||
}) | ||
}) |
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
110519
56
2542