doc-detective 2.11.0-dev.0 → 2.11.0-dev.3
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/.doc-detective.json +62 -0
- package/README.md +57 -48
- package/package.json +3 -3
- package/samples/{config.json → .doc-detective.json} +8 -7
- package/samples/doc-content-inline-tests.md +15 -14
- package/samples/doc-content.md +4 -4
- package/samples/reference.png +0 -0
- package/src/index.js +18 -6
- package/src/utils.js +33 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"envVariables": "./samples/variables.env",
|
|
3
|
+
"input": ".",
|
|
4
|
+
"output": ".",
|
|
5
|
+
"recursive": true,
|
|
6
|
+
"logLevel": "info",
|
|
7
|
+
"runTests": {
|
|
8
|
+
"detectSteps": true,
|
|
9
|
+
"input": "./samples/doc-content.md",
|
|
10
|
+
"output": "./samples",
|
|
11
|
+
"recursive": true,
|
|
12
|
+
"mediaDirectory": "./samples",
|
|
13
|
+
"downloadDirectory": "./samples"
|
|
14
|
+
},
|
|
15
|
+
"fileTypes": [
|
|
16
|
+
{
|
|
17
|
+
"name": "Markdown",
|
|
18
|
+
"extensions": [".md"],
|
|
19
|
+
"testStartStatementOpen": "[comment]: # (test start",
|
|
20
|
+
"testStartStatementClose": ")",
|
|
21
|
+
"testIgnoreStatement": "[comment]: # (test ignore)",
|
|
22
|
+
"testEndStatement": "[comment]: # (test end)",
|
|
23
|
+
"stepStatementOpen": "[comment]: # (step",
|
|
24
|
+
"stepStatementClose": ")",
|
|
25
|
+
"markup": [
|
|
26
|
+
{
|
|
27
|
+
"name": "Hyperlink",
|
|
28
|
+
"regex": ["(?<=(?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
|
|
29
|
+
"actions": ["checkLink"]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "Navigation link",
|
|
33
|
+
"regex": ["(?<=([Oo]pen|[Cc]lick) (?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
|
|
34
|
+
"actions": ["goTo"]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Onscreen text",
|
|
38
|
+
"regex": ["(?<=\\*\\*)[\\w\\s]+?(?=\\*\\*)"],
|
|
39
|
+
"actions": ["find"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "Image",
|
|
43
|
+
"regex": ["(?<=\\!\\[.*?\\]\\().*?(?=\\))"],
|
|
44
|
+
"actions": [
|
|
45
|
+
{
|
|
46
|
+
"name": "saveScreenshot",
|
|
47
|
+
"params": {
|
|
48
|
+
"directory": "samples",
|
|
49
|
+
"maxVariation": 5,
|
|
50
|
+
"overwrite": "byVariation"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"telemetry": {
|
|
59
|
+
"send": true,
|
|
60
|
+
"userId": "Doc Detective Repo"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/README.md
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
[](https://discord.gg/2M7wXEThfF)
|
|
5
5
|
[](https://doc-detective.com)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Doc Detective is an open-source documentation testing framework that makes it easy to keep your docs accurate and up-to-date. You write low-code (soon no-code) tests, and Doc Detective runs them directly against your product to make sure your docs match your user experience. Whether it’s a UI-based process or a series of API calls, Doc Detective can help you find doc bugs before your users do.
|
|
7
|
+
Doc Detective is doc content testing framework that makes it easy to keep your docs accurate and up-to-date. You write tests, and Doc Detective runs them directly against your product to make sure your docs match your user experience. Whether it’s a UI-based process or a series of API calls, Doc Detective can help you find doc bugs before your users do.
|
|
9
8
|
|
|
10
9
|
Doc Detective ingests test specifications and text files, parses them for testable actions, then executes those actions in a browser. The results (PASS/FAIL and context) are output as a JSON object so that other pieces of infrastructure can parse and manipulate them as needed.
|
|
11
10
|
|
|
12
|
-
This project handles test parsing and web-based UI testing
|
|
11
|
+
This project handles test parsing and web-based UI testing---it doesn't support results reporting or notifications. This framework is a part of testing infrastructures and needs to be complemented by other components.
|
|
13
12
|
|
|
14
13
|
## Components
|
|
15
14
|
|
|
@@ -21,84 +20,80 @@ Doc Detective has multiple components to integrate with your workflows as you ne
|
|
|
21
20
|
|
|
22
21
|
## Install
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
You can run Doc Detective as a CLI tool with Node:
|
|
27
|
-
|
|
28
|
-
0. Install prerequisites:
|
|
23
|
+
1. Install prerequisites:
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
- [Node.js](https://nodejs.org/) (tested on v18 and v20)
|
|
31
26
|
|
|
32
|
-
1.
|
|
27
|
+
1. In a terminal, install Doc Detective globally:
|
|
33
28
|
|
|
34
29
|
```bash
|
|
35
|
-
|
|
36
|
-
cd doc-detective
|
|
37
|
-
npm install
|
|
30
|
+
npm i -g doc-detective
|
|
38
31
|
```
|
|
39
32
|
|
|
40
|
-
|
|
33
|
+
If you don't install Doc Detective globally, you'll be prompted to install the first time you run an `npx` command.
|
|
34
|
+
|
|
35
|
+
## (Optional) Get sample files
|
|
41
36
|
|
|
42
|
-
To
|
|
37
|
+
To test a few samples, clone the repo and navigate to the `samples` directory:
|
|
43
38
|
|
|
44
39
|
```bash
|
|
45
|
-
|
|
40
|
+
git clone https://github.com/doc-detective/doc-detective.git
|
|
41
|
+
cd doc-detective/samples
|
|
46
42
|
```
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
## Run tests
|
|
45
|
+
|
|
46
|
+
To run your tests, use the `runTests` command:
|
|
49
47
|
|
|
50
48
|
```bash
|
|
51
|
-
|
|
49
|
+
npx doc-detective runTests
|
|
52
50
|
```
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
By default, Doc Detective scans the current directory for valid tests, but you can specify your test file with the `--input` argument. For example, to run tests in a file named `doc-content-inline-tests.md`, run the following command:
|
|
55
53
|
|
|
56
54
|
```bash
|
|
57
|
-
|
|
55
|
+
npx doc-detective runTests --input doc-content-inline-tests.md
|
|
58
56
|
```
|
|
59
57
|
|
|
60
|
-
To
|
|
58
|
+
To customize your test, file type, and directory options, create a `.doc-detective.json` [config](https://doc-detective.com/reference/schemas/config.html) file. If a `.doc-detective.json` file exists in the directory when you run the comment, Doc Detective loads the config. Otherwise, you can specify a config path with the `--config` argument.
|
|
61
59
|
|
|
62
60
|
```bash
|
|
63
|
-
|
|
61
|
+
npx doc-detective runTests --config .doc-detective.json
|
|
64
62
|
```
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
You can check the test coverage of your documentation source files with the `runCoverage` command, specifying the source file or directory of source files with the `--input` argument. Doc Detective identifies potential areas of test coverage with file-format-specific regex, and supports CommonMark syntax natively. If you want to test coverage of a file with different syntax, update your the `fileTypes` object of your [`config.json`](https://doc-detective.com/reference/schemas/config.html) file accordingly.
|
|
64
|
+
**Note**: All paths are relative to the current working directory, regardless where the config file is located.
|
|
69
65
|
|
|
66
|
+
You can override config options with command-line arguments. For example, to run tests in a file named `tests.spec.json`, even if that isn't included in your config, run the following command:
|
|
70
67
|
|
|
71
68
|
```bash
|
|
72
|
-
|
|
69
|
+
npx doc-detective runTests --config .doc-detective.json --input tests.spec.json
|
|
73
70
|
```
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
## Check your test coverage
|
|
73
|
+
|
|
74
|
+
You can check the test coverage of your documentation source files with the `runCoverage` command, specifying the source file or directory of source files with the `--input` argument. Doc Detective identifies potential areas of test coverage with file-format-specific regex, and supports CommonMark syntax natively. If you want to test coverage of a file with different syntax, update your the `fileTypes` object of your [config](https://doc-detective.com/reference/schemas/config.html) file accordingly.
|
|
76
75
|
|
|
77
76
|
```bash
|
|
78
|
-
|
|
77
|
+
npx doc-detective runCoverage --config .doc-detective.json --input doc-content.md
|
|
79
78
|
```
|
|
80
79
|
|
|
81
|
-
## Suggest tests for coverage gaps (Experimental)
|
|
82
|
-
|
|
83
|
-
The `suggestTests` command provides experimental support for suggesting tests for coverage gaps identifying during test coverage analysis. However, the `suggestTests` command is highly experimental, so usage of the command is left as an exercise for the user.
|
|
84
|
-
|
|
85
80
|
## Concepts
|
|
86
81
|
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
82
|
+
- [**Test specification**](https://doc-detective.com/reference/schemas/specification.html): A group of tests to run in one or more contexts. Conceptually parallel to a document.
|
|
83
|
+
- [**Test**](https://doc-detective.com/reference/schemas/test.html): A sequence of steps to perform. Conceptually parallel to a procedure.
|
|
84
|
+
- **Step**: A portion of a test that includes a single action. Conceptually parallel to a step in a procedure.
|
|
85
|
+
- **Action**: The task a performed in a step. Doc Detective supports a variety of actions:
|
|
86
|
+
- [**checkLink**](https://doc-detective.com/reference/schemas/checkLink.html): Check if a URL returns an acceptable status code from a GET request.
|
|
87
|
+
- [**find**](https://doc-detective.com/reference/schemas/find.html): Check if an element exists with the specified selector.
|
|
88
|
+
- [**goTo**](https://doc-detective.com/reference/schemas/goTo.html): Navigate to a specified URL.
|
|
89
|
+
- [**httpRequest**](https://doc-detective.com/reference/schemas/httpRequest.html): Perform a generic HTTP request, for example to an API.
|
|
90
|
+
- [**runShell**](https://doc-detective.com/reference/schemas/runShell.html): Perform a native shell command.
|
|
91
|
+
- [**saveScreenshot**](https://doc-detective.com/reference/schemas/saveScreenshot.html): Take a screenshot in PNG format.
|
|
92
|
+
- [**setVariables**](https://doc-detective.com/reference/schemas/setVariables.html): Load environment variables from a `.env` file.
|
|
93
|
+
- [**startRecording**](https://doc-detective.com/reference/schemas/startRecording.html) and [**stopRecording**](https://doc-detective.com/reference/schemas/stopRecording.html): Capture a video of test execution.
|
|
94
|
+
- [**typeKeys**](https://doc-detective.com/reference/schemas/typeKeys.html): Type keys. To type special keys, begin and end the string with `$` and use the special key’s enum. For example, to type the Escape key, enter `$ESCAPE$`.
|
|
95
|
+
- [**wait**](https://doc-detective.com/reference/schemas/wait.html): Pause before performing the next action.
|
|
96
|
+
- [**Context**](https://doc-detective.com/reference/schemas/context.html): An application and platforms that support the tests.
|
|
102
97
|
|
|
103
98
|
## Roadmap
|
|
104
99
|
|
|
@@ -108,9 +103,23 @@ Future updates may include support for the following items:
|
|
|
108
103
|
- Platforms: iOS, Android
|
|
109
104
|
- Commands: `suggestTests` stable release
|
|
110
105
|
|
|
106
|
+
## Develop
|
|
107
|
+
|
|
108
|
+
To develop Doc Detective, clone the repo and install dependencies:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/doc-detective/doc-detective.git
|
|
112
|
+
cd doc-detective
|
|
113
|
+
npm i
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
To run commands, use the same `npx` commands as above.
|
|
117
|
+
|
|
118
|
+
Make sure you review the [contributions guide](CONTRIBUTIONS.md) before submitting a pull request.
|
|
119
|
+
|
|
111
120
|
## Contributions
|
|
112
121
|
|
|
113
|
-
Looking to help out? See our [contributions guide](
|
|
122
|
+
Looking to help out? See our [contributions guide](CONTRIBUTIONS.md) for more info. If you can't contribute code, you can still help by reporting issues, suggesting new features, improving the documentation, or sponsoring the project.
|
|
114
123
|
|
|
115
124
|
## License
|
|
116
125
|
|
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.3",
|
|
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.
|
|
35
|
-
"doc-detective-core": "^2.11.0-dev.
|
|
34
|
+
"doc-detective-common": "^1.15.0-dev.0",
|
|
35
|
+
"doc-detective-core": "^2.11.0-dev.3",
|
|
36
36
|
"prompt-sync": "^4.2.0",
|
|
37
37
|
"yargs": "^17.7.2"
|
|
38
38
|
},
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"envVariables": "./
|
|
2
|
+
"envVariables": "./variables.env",
|
|
3
3
|
"input": ".",
|
|
4
4
|
"output": ".",
|
|
5
5
|
"recursive": true,
|
|
6
|
-
"logLevel": "
|
|
6
|
+
"logLevel": "info",
|
|
7
7
|
"runTests": {
|
|
8
|
-
"
|
|
8
|
+
"detectSteps": true,
|
|
9
|
+
"input": "./doc-content.md",
|
|
9
10
|
"output": ".",
|
|
10
11
|
"setup": "",
|
|
11
12
|
"cleanup": "",
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
"contexts": [
|
|
16
17
|
{
|
|
17
18
|
"app": {
|
|
18
|
-
"name": "
|
|
19
|
+
"name": "chrome",
|
|
19
20
|
"options": {
|
|
20
21
|
"width": 1200,
|
|
21
22
|
"height": 800,
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
{
|
|
72
73
|
"name": "saveScreenshot",
|
|
73
74
|
"params": {
|
|
74
|
-
"directory": "
|
|
75
|
+
"directory": ".",
|
|
75
76
|
"maxVariation": 5,
|
|
76
77
|
"overwrite": "byVariation"
|
|
77
78
|
}
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
],
|
|
84
85
|
"integrations": {},
|
|
85
86
|
"telemetry": {
|
|
86
|
-
"send":
|
|
87
|
-
"userId": "Doc Detective"
|
|
87
|
+
"send": true,
|
|
88
|
+
"userId": "Doc Detective Samples"
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -6,23 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com"})
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
|
|
9
|
+
The landing page discusses what Doc Detective is, what it does, and who might find it useful.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
- [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/get-started.html"})
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/config.html"})
|
|
18
|
-
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/specification.html"})
|
|
19
|
-
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/test.html"})
|
|
20
|
-
[comment]: # (step {"action":"goTo", "url":"https://doc-detective.com/reference/schemas/typeKeys.html"})
|
|
21
|
-
[comment]: # (step {"action":"find", "selector":"h2#description", "matchText":"Description"})
|
|
22
|
-
[comment]: # (step {"action":"find", "selector":"h2#fields", "matchText":"Fields"})
|
|
23
|
-
[comment]: # (step {"action":"find", "selector":"h2#examples", "matchText":"Examples"})
|
|
15
|
+
- The [references](https://doc-detective.com/reference/) detail the various JSON objects that Doc Detective expects for [configs](https://doc-detective.com/reference/schemas/config.html), [test specifications](https://doc-detective.com/reference/schemas/specification.html), [tests](https://doc-detective.com/reference/schemas/test), actions, and more. Open [typeKeys](https://doc-detective.com/reference/schemas/typeKeys.html)--or any other schema--and you'll find three sections: **Description**, **Fields**, and **Examples**.
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
[comment]: # (step {"action":"
|
|
17
|
+
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/"})
|
|
18
|
+
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/config.html"})
|
|
19
|
+
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/specification.html"})
|
|
20
|
+
[comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/test.html"})
|
|
21
|
+
[comment]: # (step {"action":"goTo", "url":"https://doc-detective.com/reference/schemas/typeKeys.html"})
|
|
22
|
+
[comment]: # (step {"action":"find", "selector":"h2#description", "matchText":"Description"})
|
|
23
|
+
[comment]: # (step {"action":"find", "selector":"h2#fields", "matchText":"Fields"})
|
|
24
|
+
[comment]: # (step {"action":"find", "selector":"h2#examples", "matchText":"Examples"})
|
|
25
|
+
|
|
26
|
+

|
|
27
27
|
|
|
28
|
+
[comment]: # (step {"action":"saveScreenshot", "path":"reference.png", "directory":"samples", "maxVariation":5, "overwrite":"byVariation"})
|
|
28
29
|
[comment]: # (test end)
|
package/samples/doc-content.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[Doc Detective documentation](https://doc-detective.com) is split into a few key sections:
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
5
|
+
- The landing page discusses what Doc Detective is, what it does, and who might find it useful.
|
|
6
|
+
- [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
|
|
7
|
+
- The [references](https://doc-detective.com/reference/) detail the various JSON objects that Doc Detective expects for [configs](https://doc-detective.com/reference/schemas/config.html), [test specifications](https://doc-detective.com/reference/schemas/specification.html), [tests](https://doc-detective.com/reference/schemas/test), actions, and more. Open [typeKeys](https://doc-detective.com/reference/schemas/typeKeys.html)--or any other schema--and you'll find three sections: **Description**, **Fields**, and **Examples**.
|
|
8
8
|
|
|
9
|
-

|
|
9
|
+

|
|
Binary file
|
package/src/index.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { runTests, runCoverage } = require("doc-detective-core");
|
|
4
|
-
const { setArgs, setConfig, outputResults } = require("./utils");
|
|
4
|
+
const { setArgs, setConfig, outputResults, setMeta } = require("./utils");
|
|
5
5
|
const { argv } = require("node:process");
|
|
6
6
|
const path = require("path");
|
|
7
|
+
const fs = require("fs");
|
|
7
8
|
|
|
9
|
+
// Run
|
|
10
|
+
setMeta();
|
|
8
11
|
main(argv);
|
|
9
12
|
|
|
10
|
-
// Run
|
|
13
|
+
// Run
|
|
11
14
|
async function main(argv) {
|
|
12
15
|
// Find index of `doc-detective` or `run` in argv
|
|
13
|
-
const index = argv.findIndex(
|
|
16
|
+
const index = argv.findIndex(
|
|
17
|
+
(arg) => arg.endsWith("doc-detective") || arg.endsWith("index.js")
|
|
18
|
+
);
|
|
14
19
|
// `command` is the next argument after `doc-detective` or `src/index.js`
|
|
15
20
|
const command = argv[index + 1];
|
|
16
|
-
// Set args
|
|
21
|
+
// Set args
|
|
17
22
|
argv = setArgs(argv);
|
|
18
|
-
|
|
23
|
+
// Get .doc-detective.json config, if it exists
|
|
24
|
+
const configPath = path.resolve(process.cwd(), ".doc-detective.json");
|
|
25
|
+
let config = {};
|
|
26
|
+
if (fs.existsSync(configPath)) {
|
|
27
|
+
config = require(configPath);
|
|
28
|
+
}
|
|
29
|
+
// Set config
|
|
30
|
+
config = setConfig(config, argv);
|
|
19
31
|
// Run command
|
|
20
32
|
let results = {};
|
|
21
33
|
let outputDir;
|
package/src/utils.js
CHANGED
|
@@ -4,11 +4,13 @@ const { validate } = require("doc-detective-common");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const { spawn } = require("child_process");
|
|
7
|
+
const os = require("os");
|
|
7
8
|
|
|
8
9
|
exports.setArgs = setArgs;
|
|
9
10
|
exports.setConfig = setConfig;
|
|
10
11
|
exports.outputResults = outputResults;
|
|
11
12
|
exports.spawnCommand = spawnCommand;
|
|
13
|
+
exports.setMeta = setMeta;
|
|
12
14
|
|
|
13
15
|
// Define args
|
|
14
16
|
function setArgs(args) {
|
|
@@ -87,7 +89,11 @@ function setConfig(config, args) {
|
|
|
87
89
|
if (args.output) config.output = args.output;
|
|
88
90
|
if (args.recursive) config.recursive = args.recursive;
|
|
89
91
|
if (args.logLevel) config.logLevel = args.logLevel;
|
|
90
|
-
if (
|
|
92
|
+
if (
|
|
93
|
+
(args.setup || args.cleanup || args.input || args.output) &&
|
|
94
|
+
!config.runTests
|
|
95
|
+
)
|
|
96
|
+
config.runTests = {};
|
|
91
97
|
if (args.input) config.runTests.input = args.input;
|
|
92
98
|
if (args.output) config.runTests.output = args.output;
|
|
93
99
|
if (args.setup) config.runTests.setup = args.setup;
|
|
@@ -154,4 +160,29 @@ async function spawnCommand(cmd, args) {
|
|
|
154
160
|
});
|
|
155
161
|
|
|
156
162
|
return { stdout, stderr, exitCode };
|
|
157
|
-
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function setMeta() {
|
|
166
|
+
const platformMap = {
|
|
167
|
+
win32: "windows",
|
|
168
|
+
darwin: "mac",
|
|
169
|
+
linux: "linux",
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Set meta
|
|
173
|
+
const meta =
|
|
174
|
+
process.env["DOC_DETECTIVE_META"] !== undefined
|
|
175
|
+
? JSON.parse(process.env["DOC_DETECTIVE_META"])
|
|
176
|
+
: {};
|
|
177
|
+
const package = require("../package.json");
|
|
178
|
+
meta.distribution = "doc-detective";
|
|
179
|
+
meta.dist_version = package.version;
|
|
180
|
+
meta.dist_platform = platformMap[os.platform()];
|
|
181
|
+
meta.dist_platform_version = os.release();
|
|
182
|
+
meta.dist_platform_arch = os.arch();
|
|
183
|
+
meta.dist_deployment = meta.dist_deployment || "node";
|
|
184
|
+
meta.dist_deployment_version =
|
|
185
|
+
meta.dist_deployment_version || process.version;
|
|
186
|
+
meta.dist_interface = meta.dist_interface || "cli";
|
|
187
|
+
process.env["DOC_DETECTIVE_META"] = JSON.stringify(meta);
|
|
188
|
+
}
|