@mintlify/prebuild 1.0.1463 → 1.0.1464
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.
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { validateMintConfig, validateDocsConfig, validateSourceRefDocsConfig, formatIssue, } from '@mintlify/validation';
|
|
1
|
+
import { validateMintConfig, validateDocsConfig, validateSourceRefDocsConfig, stripSourceRefs, formatIssue, } from '@mintlify/validation';
|
|
2
2
|
import Chalk from 'chalk';
|
|
3
3
|
import { promises as _promises } from 'fs';
|
|
4
4
|
import { outputFile } from 'fs-extra';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { resolveFileRefs } from '../resolveRefs.js';
|
|
7
7
|
const { readFile } = _promises;
|
|
8
|
-
const strippedSourceRef = Symbol('strippedSourceRef');
|
|
9
8
|
function isSourceRef(value) {
|
|
10
9
|
return (typeof value === 'object' &&
|
|
11
10
|
value !== null &&
|
|
@@ -24,22 +23,6 @@ function hasSourceRefs(value) {
|
|
|
24
23
|
}
|
|
25
24
|
return Object.values(value).some(hasSourceRefs);
|
|
26
25
|
}
|
|
27
|
-
function stripSourceRefsForLocalPreview(value) {
|
|
28
|
-
if (isSourceRef(value)) {
|
|
29
|
-
return strippedSourceRef;
|
|
30
|
-
}
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
return value
|
|
33
|
-
.map((entry) => stripSourceRefsForLocalPreview(entry))
|
|
34
|
-
.filter((entry) => entry !== strippedSourceRef);
|
|
35
|
-
}
|
|
36
|
-
if (typeof value !== 'object' || value === null) {
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
return Object.fromEntries(Object.entries(value)
|
|
40
|
-
.map(([key, entry]) => [key, stripSourceRefsForLocalPreview(entry)])
|
|
41
|
-
.filter(([, entry]) => entry !== strippedSourceRef));
|
|
42
|
-
}
|
|
43
26
|
export class ConfigUpdater {
|
|
44
27
|
constructor(type) {
|
|
45
28
|
this.validateConfigJsonString = async (configContents, strict, onError, options = {}) => {
|
|
@@ -65,9 +48,7 @@ export class ConfigUpdater {
|
|
|
65
48
|
throw Error();
|
|
66
49
|
}
|
|
67
50
|
}
|
|
68
|
-
const validationInput = allowSourceRefs && hasSourceRefEntries
|
|
69
|
-
? stripSourceRefsForLocalPreview(configObj)
|
|
70
|
-
: configObj;
|
|
51
|
+
const validationInput = allowSourceRefs && hasSourceRefEntries ? stripSourceRefs(configObj) : configObj;
|
|
71
52
|
const validationResults = this.type === 'mint' ? validateMintConfig(configObj) : validateDocsConfig(validationInput);
|
|
72
53
|
if (!validationResults.success) {
|
|
73
54
|
const errorMsg = `🚨 Invalid ${this.type}.json:`;
|