doc-detective 2.18.0 → 2.19.0-dev.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.
@@ -27,15 +27,16 @@ jobs:
27
27
  node:
28
28
  - 18
29
29
  - 20
30
+ - 22
30
31
  steps:
31
- - uses: actions/checkout@v3
32
+ - uses: actions/checkout@v4
32
33
 
33
- - uses: actions/setup-node@v3
34
+ - uses: actions/setup-node@v4
34
35
  with:
35
36
  node-version: ${{ matrix.node }}
36
37
 
37
38
  - name: Cache node_modules
38
- uses: actions/cache@v3
39
+ uses: actions/cache@v4
39
40
  with:
40
41
  # Cache key uses the contents of `package-lock.json` to identify unique cache
41
42
  key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
package/README.md CHANGED
@@ -33,14 +33,7 @@ Doc Detective has multiple components to integrate with your workflows as you ne
33
33
 
34
34
  If you don't install Doc Detective globally, you'll be prompted to install the first time you run an `npx` command.
35
35
 
36
- ## (Optional) Get sample files
37
-
38
- To test a few samples, clone the repo and navigate to the `samples` directory:
39
-
40
- ```bash
41
- git clone https://github.com/doc-detective/doc-detective.git
42
- cd doc-detective/samples
43
- ```
36
+ **Note:** If you're working in a cloned `doc-detective` repository, run `npm i` to install local dependencies or the `npx` command in the next step will fail.
44
37
 
45
38
  ## Run tests
46
39
 
@@ -70,6 +63,10 @@ You can override config options with command-line arguments. For example, to run
70
63
  npx doc-detective runTests --config .doc-detective.json --input tests.spec.json
71
64
  ```
72
65
 
66
+ ### Check out some samples
67
+
68
+ You can find test and config samples in the [samples](https://github.com/doc-detective/doc-detective/tree/main/samples) directory.
69
+
73
70
  ## Check your test coverage
74
71
 
75
72
  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 the `fileTypes` object of your [config](https://doc-detective.com/docs/references/schemas/config.html) file accordingly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-detective",
3
- "version": "2.18.0",
3
+ "version": "2.19.0-dev.0",
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"
@@ -9,7 +9,9 @@
9
9
  "scripts": {
10
10
  "mocha": "mocha",
11
11
  "test": "mocha test/*.test.js",
12
+ "prerunTests": "node ./src/checkDependencies.js",
12
13
  "runTests": "node ./src/index.js runTests",
14
+ "prerunCoverage": "node ./src/checkDependencies.js",
13
15
  "runCoverage": "node ./src/index.js runCoverage",
14
16
  "dev": "node ./dev"
15
17
  },
@@ -32,13 +34,13 @@
32
34
  "homepage": "https://github.com/doc-detective/doc-detective#readme",
33
35
  "dependencies": {
34
36
  "@ffmpeg-installer/ffmpeg": "^1.1.0",
35
- "doc-detective-common": "^1.21.0",
36
- "doc-detective-core": "^2.18.0",
37
+ "doc-detective-common": "1.22.0-dev.2",
38
+ "doc-detective-core": "2.19.0-dev.0",
37
39
  "prompt-sync": "^4.2.0",
38
40
  "yargs": "^17.7.2"
39
41
  },
40
42
  "devDependencies": {
41
- "chai": "^5.1.1",
42
- "mocha": "^10.7.3"
43
+ "chai": "^5.1.2",
44
+ "mocha": "^11.1.0"
43
45
  }
44
46
  }
@@ -65,6 +65,7 @@
65
65
  "regex": ["!\\[.+?\\]\\((.+?)\\)"],
66
66
  "actions": [
67
67
  {
68
+ "id": "reference",
68
69
  "action": "saveScreenshot",
69
70
  "maxVariation": 5,
70
71
  "overwrite": "byVariation"
@@ -4,7 +4,7 @@
4
4
 
5
5
  - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
6
6
 
7
- - [Get started](https://doc-detective.com/docs/get-started.html) covers how to quickly get up and running with Doc Detective.
7
+ - [Get started](https://doc-detective.com/docs/get-started/intro) covers how to quickly get up and running with Doc Detective.
8
8
 
9
9
  - The [references](https://doc-detective.com/docs/category/schemas) detail the various JSON objects that Doc Detective expects for [configs](https://doc-detective.com/docs/references/schemas/config.html), [test specifications](https://doc-detective.com/docs/references/schemas/specification.html), [tests](https://doc-detective.com/docs/references/schemas/test), actions, and more. Open [typeKeys](https://doc-detective.com/docs/references/schemas/typeKeys.html)--or any other schema--and you'll find two sections: **Fields** and **Examples**.
10
10
 
@@ -8,9 +8,9 @@
8
8
 
9
9
  - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
10
10
 
11
- - [Get started](https://doc-detective.com/docs/get-started.html) covers how to quickly get up and running with Doc Detective.
11
+ - [Get started](https://doc-detective.com/docs/get-started/intro) covers how to quickly get up and running with Doc Detective.
12
12
 
13
- [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/docs/get-started.html"})
13
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/docs/get-started/intro"})
14
14
 
15
15
  - The [references](https://doc-detective.com/docs/category/schemas) detail the various JSON objects that Doc Detective expects for [configs](https://doc-detective.com/docs/references/schemas/config.html), [test specifications](https://doc-detective.com/docs/references/schemas/specification.html), [tests](https://doc-detective.com/docs/references/schemas/test), actions, and more. Open [typeKeys](https://doc-detective.com/docs/references/schemas/typeKeys.html)--or any other schema--and you'll find two sections: **Fields** and **Examples**.
16
16
 
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+ const readline = require("readline");
6
+
7
+ // Check if package.json exists, and if it's for doc-detective
8
+ if (fs.existsSync(path.resolve(process.cwd(), "package.json"))) {
9
+ try {
10
+ const json = JSON.parse(
11
+ fs.readFileSync(path.resolve(process.cwd(), "package.json"))
12
+ );
13
+ if (json.name === "doc-detective") {
14
+ // Check if dependencies are installed
15
+ checkDependencies();
16
+ }
17
+ } catch (error) {
18
+ console.error(`Failed to parse package.json: ${error.message}`);
19
+ }
20
+ }
21
+
22
+ // Check if dependencies are installed
23
+ function checkDependencies() {
24
+ if (!fs.existsSync(path.resolve(process.cwd(), "node_modules"))) {
25
+ const rl = readline.createInterface({
26
+ input: process.stdin,
27
+ output: process.stdout,
28
+ });
29
+
30
+ // Handle SIGINT (Ctrl+C)
31
+ rl.on('SIGINT', () => {
32
+ console.log('\nOperation cancelled by user');
33
+ rl.close();
34
+ process.exit(0);
35
+ });
36
+
37
+ rl.question(
38
+ "It looks like you haven't installed the local dependencies yet. Would you like to install them now? (yes/no): ",
39
+ (answer) => {
40
+ const normalizedAnswer = answer.toLowerCase().trim();
41
+ if (normalizedAnswer === "yes" || normalizedAnswer === "y") {
42
+ console.log("Installing dependencies. This may take a few minutes.");
43
+ const { spawn } = require("child_process");
44
+ const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
45
+ const install = spawn(npmCmd, ["install"], {
46
+ stdio: "inherit",
47
+ shell: true
48
+ });
49
+
50
+ // Set timeout
51
+ const timeout = setTimeout(() => {
52
+ console.error('Installation timed out after 5 minutes');
53
+ install.kill();
54
+ rl.close();
55
+ }, 5 * 60 * 1000);
56
+
57
+ install.on("close", (code) => {
58
+ clearTimeout(timeout);
59
+ if (code !== 0) {
60
+ console.error(
61
+ `Failed to install dependencies (exit code ${code}). Try running 'npm install' manually and check for errors.`
62
+ );
63
+ process.exit(1);
64
+ } else {
65
+ console.log("Dependencies installed successfully.");
66
+ }
67
+ rl.close();
68
+ });
69
+
70
+ install.on("error", (error) => {
71
+ clearTimeout(timeout);
72
+ console.error(`Failed to start 'npm install': ${error.message}`);
73
+ rl.close();
74
+ process.exit(1);
75
+ });
76
+ } else {
77
+ console.log("Dependencies not installed. Please run 'npm install' manually before proceeding.");
78
+ rl.close();
79
+ process.exit(1);
80
+ }
81
+ }
82
+ );
83
+ }
84
+ }
@@ -6,8 +6,8 @@
6
6
  [comment]: # (step {"action":"goTo", "url":"https://doc-detective.com"})
7
7
 
8
8
  - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
9
- - [Get started](https://doc-detective.com/docs/get-started.html) covers how to quickly get up and running with Doc Detective.
10
- [comment]: # (step {"action":"goTo", "url":"https://doc-detective.com/docs/get-started.html"})
9
+ - [Get started](https://doc-detective.com/docs/get-started/intro) covers how to quickly get up and running with Doc Detective.
10
+ [comment]: # (step {"action":"goTo", "url":"https://doc-detective.com/docs/get-started/intro"})
11
11
  - The [references](https://doc-detective.com/docs/references/schemas/typeKeys) detail the various JSON objects that Doc Detective expects for configs, test specifications, tests, actions, and more. Each object schema includes an object description, field definitions, and examples.
12
12
  [comment]: # (step {"action":"goTo", "url":"https://doc-detective.com/docs/references/schemas/typeKeys"})
13
13
  [comment]: # (step {"action":"find", "selector":"h2#fields", "matchText":"Fields"})