doc-detective 2.19.1-dev.0 → 3.0.0
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/.github/FUNDING.yml +14 -14
- package/.github/dependabot.yml +11 -11
- package/.github/workflows/electron-publish.yml +17 -17
- package/.github/workflows/npm-publish.yml +57 -57
- package/.github/workflows/npm-test.yaml +50 -50
- package/CONTRIBUTIONS.md +27 -27
- package/LICENSE +661 -21
- package/README.md +108 -124
- package/dev/dev.spec.json +62 -62
- package/dev/index.js +5 -5
- package/package.json +44 -46
- package/samples/.doc-detective.json +83 -83
- package/samples/doc-content-detect.md +10 -10
- package/samples/doc-content-inline-tests.md +27 -27
- package/samples/docker-hello.spec.json +14 -14
- package/samples/http.spec.json +26 -26
- package/samples/kitten-search-inline.md +15 -15
- package/samples/kitten-search.spec.json +28 -28
- package/samples/tests.spec.json +70 -70
- package/samples/variables.env +4 -4
- package/src/checkDependencies.js +84 -84
- package/src/index.js +49 -79
- package/src/utils.js +471 -251
- package/test/artifacts/cleanup.spec.json +18 -18
- package/test/artifacts/config.json +44 -44
- package/test/artifacts/doc-content.md +15 -15
- package/test/artifacts/env +2 -2
- package/test/artifacts/httpRequest.spec.json +55 -55
- package/test/artifacts/runShell.spec.json +29 -29
- package/test/artifacts/setup.spec.json +18 -18
- package/test/artifacts/test.spec.json +60 -60
- package/test/runTests.test.js +22 -22
- package/test/test-config.json +12 -12
- package/test/test-results.json +124 -124
- package/test/utils.test.js +170 -210
- package/test/runCoverage.test.js +0 -20
package/src/index.js
CHANGED
|
@@ -1,79 +1,49 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { runTests, runCoverage } = require("doc-detective-core");
|
|
4
|
-
const {
|
|
5
|
-
const {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
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
|
-
You can skip this next time by running 'npx doc-detective <command>'. You can also set 'defaultCommand' in your .doc-detective.json config file.
|
|
52
|
-
|
|
53
|
-
For more info, visit https://doc-detective.com.
|
|
54
|
-
|
|
55
|
-
Command: `;
|
|
56
|
-
command = prompt({
|
|
57
|
-
ask,
|
|
58
|
-
value: "runTests",
|
|
59
|
-
autocomplete: complete(["runTests", "runCoverage"]),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Run command
|
|
64
|
-
let results = {};
|
|
65
|
-
let output;
|
|
66
|
-
if (command === "runCoverage") {
|
|
67
|
-
output = config?.runCoverage?.output || config.output;
|
|
68
|
-
results = await runCoverage(config);
|
|
69
|
-
} else if (command === "runTests") {
|
|
70
|
-
output = config?.runTests?.output || config.output;
|
|
71
|
-
results = await runTests(config);
|
|
72
|
-
} else {
|
|
73
|
-
console.error(`Sorry, that's not a recognized command. Please try again.`);
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Output results
|
|
78
|
-
await outputResults(config, output, results, { command });
|
|
79
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { runTests, runCoverage } = require("doc-detective-core");
|
|
4
|
+
const { readFile } = require("doc-detective-common");
|
|
5
|
+
const { setArgs, setConfig, outputResults, setMeta } = require("./utils");
|
|
6
|
+
const { argv } = require("node:process");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
|
|
10
|
+
// Run
|
|
11
|
+
setMeta();
|
|
12
|
+
main(argv);
|
|
13
|
+
|
|
14
|
+
// Run
|
|
15
|
+
async function main(argv) {
|
|
16
|
+
// Find index of `doc-detective` or `run` in argv
|
|
17
|
+
const index = argv.findIndex(
|
|
18
|
+
(arg) => arg.endsWith("doc-detective") || arg.endsWith("index.js")
|
|
19
|
+
);
|
|
20
|
+
// Set args
|
|
21
|
+
argv = setArgs(argv);
|
|
22
|
+
// Get .doc-detective JSON or YAML config, if it exists
|
|
23
|
+
const configPathJSON = path.resolve(process.cwd(), ".doc-detective.json");
|
|
24
|
+
const configPathYAML = path.resolve(process.cwd(), ".doc-detective.yaml");
|
|
25
|
+
const configPathYML = path.resolve(process.cwd(), ".doc-detective.yml");
|
|
26
|
+
const configPath = fs.existsSync(argv.config)
|
|
27
|
+
? argv.config
|
|
28
|
+
: fs.existsSync(configPathJSON)
|
|
29
|
+
? configPathJSON
|
|
30
|
+
: fs.existsSync(configPathYAML)
|
|
31
|
+
? configPathYAML
|
|
32
|
+
: fs.existsSync(configPathYML)
|
|
33
|
+
? configPathYML
|
|
34
|
+
: null;
|
|
35
|
+
// If config file exists, read it
|
|
36
|
+
let config = {};
|
|
37
|
+
if (configPath) {
|
|
38
|
+
config = await readFile({ fileURLOrPath: configPath });
|
|
39
|
+
}
|
|
40
|
+
// Set config
|
|
41
|
+
config = await setConfig(config, argv, configPath || ".");
|
|
42
|
+
|
|
43
|
+
// Run tests
|
|
44
|
+
const output = config.output;
|
|
45
|
+
const results = await runTests(config);
|
|
46
|
+
|
|
47
|
+
// Output results
|
|
48
|
+
await outputResults(config, output, results, { command: "runTests" });
|
|
49
|
+
}
|