@mikaello/avrodoc-plus
Advanced tools
Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "@mikaello/avrodoc-plus", | ||
"description": "Documentation tool for Avro schemas. Forked from https://github.com/leosilvadev/avrodoc-plus.", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"author": "mikaello https://github.com/mikaello", | ||
@@ -6,0 +6,0 @@ "type": "module", |
@@ -19,13 +19,19 @@ /** | ||
*/ | ||
async function createAvroDoc(extra_less_files, inputfiles, outputfile) { | ||
async function createAvroDoc( | ||
extra_less_files, | ||
inputfiles, | ||
outputfile, | ||
ignoreInvalid | ||
) { | ||
avrodocDebug(`Creating ${outputfile} from `, inputfiles); | ||
let schemata = inputfiles.map(function (filename) { | ||
return { | ||
json: readJSON(filename), | ||
filename: filename, | ||
}; | ||
}); | ||
let schemata = inputfiles | ||
.map((filename) => { | ||
const json = readJSON(filename, ignoreInvalid); | ||
return json != null ? { json, filename } : null; | ||
}) | ||
.filter((s) => s != null); | ||
const html = await topLevelHTML(extra_less_files, { | ||
inline: true, | ||
schemata: schemata, | ||
schemata, | ||
}); | ||
@@ -54,5 +60,6 @@ return await writeAvroDoc(outputfile, html); | ||
* @param {string} filename to be read | ||
* @param {boolean} ignoreInvalid should we ignore invalid JSON files | ||
* @returns {object} with parsed AVRO | ||
*/ | ||
function readJSON(filename) { | ||
function readJSON(filename, ignoreInvalid) { | ||
let json, parsed; | ||
@@ -64,3 +71,6 @@ avrodocDebug("Parsing ", filename); | ||
} catch (e) { | ||
console.error("Not a valid json file: " + filename); | ||
console.error("Not a valid JSON file: " + filename); | ||
if (ignoreInvalid) { | ||
return; | ||
} | ||
process.exit(1); | ||
@@ -67,0 +77,0 @@ } |
@@ -28,2 +28,4 @@ /** | ||
"-s": "--style", | ||
"--ignore-invalid": Boolean, | ||
}); | ||
@@ -33,2 +35,3 @@ | ||
let outputFile = null; | ||
let ignoreInvalidSchemas = false; | ||
@@ -51,10 +54,14 @@ // Determine list of input files file1.avsc file2.avsc | ||
if (argv["--ignore-invalid"]) { | ||
ignoreInvalidSchemas = true; | ||
} | ||
//valid input? | ||
if (!inputFiles || inputFiles.length === 0 || outputFile === null) { | ||
console.error( | ||
"Usage: avrodoc [-i rootfolder] [my-schema.avsc [another-schema.avsc...]] [-o my-documentation.html] [-s my-style.less]" | ||
"Usage: avrodoc [-i rootfolder] [my-schema.avsc [another-schema.avsc...]] [-o my-documentation.html] [-s my-style.less] [--ignore-invalid]" | ||
); | ||
process.exit(1); | ||
} | ||
createAvroDoc(extra_less_files, inputFiles, outputFile); | ||
createAvroDoc(extra_less_files, inputFiles, outputFile, ignoreInvalidSchemas); | ||
@@ -61,0 +68,0 @@ //private stuff |
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
640618
15489