@mintlify/prebuild 1.0.319 → 1.0.320
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/prebuild/update/ConfigUpdater.d.ts +1880 -2119
- package/dist/prebuild/update/ConfigUpdater.js +10 -28
- package/dist/prebuild/update/docsConfig/index.d.ts +0 -1931
- package/dist/prebuild/update/docsConfig/index.js +1 -5
- package/dist/prebuild/update/index.d.ts +1 -0
- package/dist/prebuild/update/index.js +1 -0
- package/dist/prebuild/update/mintConfig/index.d.ts +0 -242
- package/dist/prebuild/update/mintConfig/index.js +4 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -5,19 +5,10 @@ import fse from 'fs-extra';
|
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
const { readFile } = _promises;
|
|
7
7
|
export class ConfigUpdater {
|
|
8
|
-
static getInstance(type) {
|
|
9
|
-
if (!ConfigUpdater.instances.has(type)) {
|
|
10
|
-
ConfigUpdater.instances.set(type, new ConfigUpdater(type));
|
|
11
|
-
}
|
|
12
|
-
return ConfigUpdater.instances.get(type);
|
|
13
|
-
}
|
|
14
8
|
constructor(type) {
|
|
15
|
-
this.
|
|
16
|
-
if (this.type !== 'mint') {
|
|
17
|
-
throw Error('validateMintConfigJson is only available for mint.json');
|
|
18
|
-
}
|
|
9
|
+
this.validateConfigJsonString = async (configContents) => {
|
|
19
10
|
const configObj = this.parseConfigJson(configContents);
|
|
20
|
-
const validationResults = validateMintConfig(configObj);
|
|
11
|
+
const validationResults = this.type === 'mint' ? validateMintConfig(configObj) : validateDocsConfig(configObj);
|
|
21
12
|
if (!validationResults.success) {
|
|
22
13
|
console.error(Chalk.red(`🚨 Invalid ${this.type}.json:`));
|
|
23
14
|
validationResults.error.issues.forEach((issue) => console.error(Chalk.red(formatIssue(issue))));
|
|
@@ -29,20 +20,7 @@ export class ConfigUpdater {
|
|
|
29
20
|
validationResults.warnings.forEach((issue) => console.warn(Chalk.yellow(formatIssue(issue))));
|
|
30
21
|
}
|
|
31
22
|
}
|
|
32
|
-
return validationResults;
|
|
33
|
-
};
|
|
34
|
-
this.validateDocsConfigJson = async (configContents) => {
|
|
35
|
-
if (this.type !== 'docs') {
|
|
36
|
-
throw Error('validateDocsConfigJson is only available for docs.json');
|
|
37
|
-
}
|
|
38
|
-
const configObj = this.parseConfigJson(configContents);
|
|
39
|
-
const validationResults = validateDocsConfig(configObj);
|
|
40
|
-
if (!validationResults.success) {
|
|
41
|
-
console.error(Chalk.red(`🚨 Invalid ${this.type}.json:`));
|
|
42
|
-
validationResults.error.issues.forEach((issue) => console.error(Chalk.red(formatIssue(issue))));
|
|
43
|
-
throw Error();
|
|
44
|
-
}
|
|
45
|
-
return validationResults;
|
|
23
|
+
return { ...validationResults, data: validationResults.data };
|
|
46
24
|
};
|
|
47
25
|
this.readConfigFile = async (configPath) => {
|
|
48
26
|
let configContents;
|
|
@@ -87,7 +65,11 @@ export class ConfigUpdater {
|
|
|
87
65
|
getConfigType() {
|
|
88
66
|
return this.type;
|
|
89
67
|
}
|
|
68
|
+
async getConfig(configPath) {
|
|
69
|
+
const configContents = await this.readConfigFile(configPath);
|
|
70
|
+
const validationResults = await this.validateConfigJsonString(configContents);
|
|
71
|
+
return validationResults.data;
|
|
72
|
+
}
|
|
90
73
|
}
|
|
91
|
-
|
|
92
|
-
export const
|
|
93
|
-
export const DocsConfigUpdater = ConfigUpdater.getInstance('docs');
|
|
74
|
+
export const MintConfigUpdater = new ConfigUpdater('mint');
|
|
75
|
+
export const DocsConfigUpdater = new ConfigUpdater('docs');
|