doc-detective 2.11.0-dev.3 → 2.11.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.js +31 -3
- package/samples/reference.png +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doc-detective",
|
|
3
|
-
"version": "2.11.0-dev.
|
|
3
|
+
"version": "2.11.0-dev.4",
|
|
4
4
|
"description": "Treat doc content as testable assertions to validate doc accuracy and product UX.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"doc-detective": "src/index.js"
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/doc-detective/doc-detective#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"doc-detective-common": "^1.15.0-dev.
|
|
35
|
-
"doc-detective-core": "^2.11.0-dev.
|
|
34
|
+
"doc-detective-common": "^1.15.0-dev.1",
|
|
35
|
+
"doc-detective-core": "^2.11.0-dev.4",
|
|
36
36
|
"prompt-sync": "^4.2.0",
|
|
37
37
|
"yargs": "^17.7.2"
|
|
38
38
|
},
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { runTests, runCoverage } = require("doc-detective-core");
|
|
4
4
|
const { setArgs, setConfig, outputResults, setMeta } = require("./utils");
|
|
5
5
|
const { argv } = require("node:process");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const fs = require("fs");
|
|
8
|
+
const prompt = require("prompt-sync")();
|
|
9
|
+
|
|
10
|
+
function complete(commands) {
|
|
11
|
+
return function (str) {
|
|
12
|
+
var i;
|
|
13
|
+
var ret = [];
|
|
14
|
+
for (i=0; i< commands.length; i++) {
|
|
15
|
+
if (commands[i].indexOf(str) == 0)
|
|
16
|
+
ret.push(commands[i]);
|
|
17
|
+
}
|
|
18
|
+
return ret;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
8
21
|
|
|
9
22
|
// Run
|
|
10
23
|
setMeta();
|
|
@@ -17,7 +30,21 @@ async function main(argv) {
|
|
|
17
30
|
(arg) => arg.endsWith("doc-detective") || arg.endsWith("index.js")
|
|
18
31
|
);
|
|
19
32
|
// `command` is the next argument after `doc-detective` or `src/index.js`
|
|
20
|
-
|
|
33
|
+
let command = argv[index + 1];
|
|
34
|
+
// If no command, prompt user to select a command
|
|
35
|
+
if (command !== "runTests" && command !== "runCoverage") {
|
|
36
|
+
const ask = `
|
|
37
|
+
Welcome to Doc Detective. Choose a command:
|
|
38
|
+
- 'runTests' - Run tests defined in specifications and documentation source files.
|
|
39
|
+
- 'runCoverage' - Calculate test coverage of doc content.
|
|
40
|
+
|
|
41
|
+
You can skip this next time by running 'npx doc-detective <command>'. You can also set 'defaultCommand' in your .doc-detective.json config file.
|
|
42
|
+
|
|
43
|
+
For more info, visit https://doc-detective.com.
|
|
44
|
+
|
|
45
|
+
Command: `;
|
|
46
|
+
command = prompt({ask, value: "runTests", autocomplete: complete(["runTests", "runCoverage"])});
|
|
47
|
+
}
|
|
21
48
|
// Set args
|
|
22
49
|
argv = setArgs(argv);
|
|
23
50
|
// Get .doc-detective.json config, if it exists
|
|
@@ -41,7 +68,8 @@ async function main(argv) {
|
|
|
41
68
|
outputReportType = "testResults";
|
|
42
69
|
results = await runTests(config);
|
|
43
70
|
} else {
|
|
44
|
-
|
|
71
|
+
console.error(`Sorry, that's not a recognized command. Please try again.`);
|
|
72
|
+
process.exit(1);
|
|
45
73
|
}
|
|
46
74
|
// Output results
|
|
47
75
|
const outputPath = path.resolve(
|
package/samples/reference.png
DELETED
|
Binary file
|