Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | 24x 24x 1x 23x 3x 3x 3x 3x 2x 1x 1x 1x 1x 20x 6x 6x 5x 6x 3x 1x 1x 5x 5x 5x 5x 14x 12x 12x 12x 17x 17x 8x 8x 3x 3x 5x 5x 5x 9x 8x 12x 7x 7x 5x 5x 5x 5x 5x 5x 5x 2x 2x | #!/usr/bin/env node
import { validateProjectDirectory } from "./project.js";
import { checkProjectDirectory } from "./check-command.js";
import { reportProjectDirectory } from "./report.js";
const [command, ...commandArguments] = process.argv.slice(2);
if (command === "--version" || command === "-v") {
console.log("moura 0.2.1");
} else if (command === "validate") {
Iif (commandArguments.length > 1) {
console.error("Usage: moura validate [directory]");
process.exitCode = 1;
} else {
const directory = commandArguments[0] ?? process.cwd();
const result = await validateProjectDirectory(directory);
if (result.errors.length === 0) {
console.log("✓ Traceability is valid");
} else {
console.error("✗ Traceability validation failed");
for (const problem of result.errors)
console.error(`- ${problem.message}`);
process.exitCode = 1;
}
}
} else if (command === "check") {
const strict = commandArguments.includes("--strict-traceability");
const directories = commandArguments.filter(
(argument) => argument !== "--strict-traceability",
);
if (
directories.length > 1 ||
commandArguments.some(
(argument) =>
argument.startsWith("--") && argument !== "--strict-traceability",
)
) {
console.error("Usage: moura check [directory] [--strict-traceability]");
process.exitCode = 1;
} else {
const result = await checkProjectDirectory(
directories[0] ?? process.cwd(),
{ strictTraceability: strict },
);
for (const line of result.stdout) console.log(line);
for (const line of result.stderr) console.error(line);
process.exitCode = result.exitCode;
}
} else if (command === "report") {
const directories: string[] = [];
let output: string | undefined;
let japaneseViews: string | undefined;
let allureReport: string | undefined;
let coverageReport: string | undefined;
let invalid = false;
for (let index = 0; index < commandArguments.length; index++) {
const argument = commandArguments[index]!;
if (
[
"--output",
"--japanese-views",
"--allure-report",
"--coverage-report",
].includes(argument)
) {
const value = commandArguments[++index];
if (!value || value.startsWith("--")) {
invalid = true;
break;
}
if (argument === "--output") {
if (output !== undefined) invalid = true;
output = value;
} else Eif (argument === "--allure-report") {
if (allureReport !== undefined) invalid = true;
allureReport = value;
} else if (argument === "--coverage-report") {
if (coverageReport !== undefined) invalid = true;
coverageReport = value;
} else {
if (japaneseViews !== undefined) invalid = true;
japaneseViews = value;
}
} else if (argument.startsWith("-")) invalid = true;
else directories.push(argument);
}
if (invalid || directories.length > 1) {
console.error(
"Usage: moura report [directory] [--output <directory>] [--allure-report <directory>] [--coverage-report <directory>] [--japanese-views <json>]\nReport output must not exist, even as an empty directory. Remove it yourself before regenerating.",
);
process.exitCode = 1;
} else {
const result = await reportProjectDirectory(
directories[0] ?? process.cwd(),
{
...(allureReport === undefined ? {} : { allureReport }),
...(coverageReport === undefined ? {} : { coverageReport }),
...(output === undefined ? {} : { output }),
...(japaneseViews === undefined ? {} : { japaneseViews }),
},
);
Eif (result.overviewPath)
console.log(`✓ Quality Overview: ${result.overviewPath}`);
Eif (result.outputPath)
console.log(`✓ Requirement coverage report: ${result.outputPath}`);
for (const error of result.errors) console.error(`- ${error}`);
process.exitCode = result.exitCode;
}
} else {
console.log(
[
"Moura is in early development.",
"Available commands: validate, check, report.",
"Usage: moura report [directory] [--output <directory>] [--allure-report <directory>] [--coverage-report <directory>] [--japanese-views <json>]",
"Report output must not exist, even as an empty directory. Remove it yourself before regenerating.",
].join("\n"),
);
Iif (command && command !== "--help" && command !== "-h") {
process.exitCode = 1;
}
}
|