@mintlify/link-rot 3.0.1037 → 3.0.1039
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/graph.d.ts +5 -0
- package/dist/graph.js +61 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/static-checking/getBrokenRedirects.d.ts +6 -0
- package/dist/static-checking/getBrokenRedirects.js +16 -0
- package/dist/static-checking/getNavigationHrefs.js +9 -14
- package/dist/static-checking/getOpenApiPagePaths.d.ts +7 -2
- package/dist/static-checking/getOpenApiPagePaths.js +46 -30
- package/dist/static-checking/getRedirects.js +6 -17
- package/dist/static-checking/readConfig.d.ts +7059 -0
- package/dist/static-checking/readConfig.js +47 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { resolveFileRefs } from '@mintlify/prebuild';
|
|
11
|
+
import { validateDocsConfig, validateMintConfig } from '@mintlify/validation';
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
/**
|
|
15
|
+
* Read docs.json (preferred) or mint.json from `baseDir` and resolve any
|
|
16
|
+
* `$ref` pointers inside it to sibling JSON files. Returns the fully
|
|
17
|
+
* expanded object, matching what production sees after `getConfigObj`.
|
|
18
|
+
*
|
|
19
|
+
* Returns `null` when neither config exists or when parsing/resolution fails.
|
|
20
|
+
*/
|
|
21
|
+
export const readResolvedConfigJson = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const order = ['docs.json', 'mint.json'];
|
|
23
|
+
for (const configFile of order) {
|
|
24
|
+
const configPath = path.join(baseDir, configFile);
|
|
25
|
+
if (!fs.existsSync(configPath))
|
|
26
|
+
continue;
|
|
27
|
+
try {
|
|
28
|
+
const parsed = yield fs.readJSON(configPath);
|
|
29
|
+
const { resolved } = yield resolveFileRefs(parsed, baseDir);
|
|
30
|
+
if (resolved && typeof resolved === 'object' && !Array.isArray(resolved)) {
|
|
31
|
+
return { configFile, json: resolved };
|
|
32
|
+
}
|
|
33
|
+
// Resolved to a non-object (malformed config) — try the next candidate.
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.warn(`Warning: Failed to read or resolve ${configFile}: ${err}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
});
|
|
41
|
+
export const readResolvedConfigJsonAndValidate = (baseDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
const resolvedConfigJson = yield readResolvedConfigJson(baseDir);
|
|
43
|
+
if (!resolvedConfigJson)
|
|
44
|
+
return null;
|
|
45
|
+
const validate = resolvedConfigJson.configFile === 'docs.json' ? validateDocsConfig : validateMintConfig;
|
|
46
|
+
return validate(resolvedConfigJson.json);
|
|
47
|
+
});
|