mcp-medic 1.2.5 → 1.2.6
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/dist/fleet.js +41 -14
- package/package.json +1 -1
package/dist/fleet.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { readdirSync,
|
|
2
|
-
import { join } from 'node:path';
|
|
1
|
+
import { readdirSync, lstatSync, readFileSync, existsSync } from 'node:fs';
|
|
2
|
+
import { resolve, join } from 'node:path';
|
|
3
3
|
import { loadConfig } from './config-loader.js';
|
|
4
4
|
import { runChecks } from './orchestrator.js';
|
|
5
5
|
import { allChecks } from './checks/index.js';
|
|
6
6
|
import { redactRecord } from './redact.js';
|
|
7
|
-
function findFilesMatching(dir, pattern, results = []) {
|
|
7
|
+
function findFilesMatching(dir, rootDir, pattern, results = []) {
|
|
8
8
|
if (!existsSync(dir))
|
|
9
9
|
return results;
|
|
10
|
-
|
|
10
|
+
let entries;
|
|
11
|
+
try {
|
|
12
|
+
entries = readdirSync(dir).sort();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return results;
|
|
16
|
+
}
|
|
11
17
|
for (const entry of entries) {
|
|
12
18
|
if (entry === 'node_modules' || entry === '.git' || entry === 'dist')
|
|
13
19
|
continue;
|
|
14
20
|
const fullPath = join(dir, entry);
|
|
15
21
|
try {
|
|
16
|
-
const stat =
|
|
22
|
+
const stat = lstatSync(fullPath);
|
|
17
23
|
if (stat.isDirectory()) {
|
|
18
|
-
findFilesMatching(fullPath, pattern, results);
|
|
24
|
+
findFilesMatching(fullPath, rootDir, pattern, results);
|
|
19
25
|
}
|
|
20
|
-
else if (stat.isFile()
|
|
26
|
+
else if (stat.isFile()) {
|
|
27
|
+
const relativePath = fullPath.slice(rootDir.length + 1).split('\\').join('/');
|
|
28
|
+
if (!pattern.test(relativePath))
|
|
29
|
+
continue;
|
|
21
30
|
results.push(fullPath);
|
|
22
31
|
}
|
|
23
32
|
}
|
|
@@ -31,13 +40,31 @@ function findFilesMatching(dir, pattern, results = []) {
|
|
|
31
40
|
* Discovers config files matching a glob or pattern.
|
|
32
41
|
*/
|
|
33
42
|
export function findConfigFiles(globOrPattern, rootDir = process.cwd()) {
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
const root = resolve(rootDir);
|
|
44
|
+
const glob = globOrPattern.split('\\').join('/').replace(/^\.\//, '');
|
|
45
|
+
let regexSource = '^';
|
|
46
|
+
for (let i = 0; i < glob.length; i += 1) {
|
|
47
|
+
const char = glob[i];
|
|
48
|
+
if (char === '*' && glob[i + 1] === '*') {
|
|
49
|
+
i += 1;
|
|
50
|
+
if (glob[i + 1] === '/') {
|
|
51
|
+
// A leading or interior **/ can match zero or more path segments.
|
|
52
|
+
regexSource += '(?:.*/)?';
|
|
53
|
+
i += 1;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
regexSource += '.*';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (char === '*') {
|
|
60
|
+
regexSource += '[^/]*';
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
regexSource += char.replace(/[|\\{}()[\]^$+?.]/g, '\\$&');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const regex = new RegExp(`${regexSource}$`);
|
|
67
|
+
return findFilesMatching(root, root, regex).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
41
68
|
}
|
|
42
69
|
/**
|
|
43
70
|
* Runs validation checks across all matching configuration files.
|