@mintlify/previewing 4.0.269 → 4.0.271
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/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/local-preview/listener/getDocsState.d.ts +6 -0
- package/dist/local-preview/listener/getDocsState.js +21 -0
- package/dist/local-preview/listener/index.js +5 -9
- package/dist/local-preview/listener/update.d.ts +2 -2
- package/dist/local-preview/listener/update.js +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -2,7 +2,7 @@ import os from 'os';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import * as url from 'url';
|
|
4
4
|
// Change this to bump to a newer version of mint's client
|
|
5
|
-
export const TARGET_MINT_VERSION = 'v0.0.
|
|
5
|
+
export const TARGET_MINT_VERSION = 'v0.0.697';
|
|
6
6
|
// package installation location
|
|
7
7
|
export const INSTALL_PATH = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
8
|
export const HOME_DIR = os.homedir();
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { validateMintJson, generateOpenApiAnchorsOrTabs, categorizeFilePaths, } from '@mintlify/prebuild';
|
|
11
|
+
import { promises as _promises } from 'fs';
|
|
12
|
+
import { join } from 'path';
|
|
13
|
+
import { CMD_EXEC_PATH, CLIENT_PATH } from '../../constants.js';
|
|
14
|
+
const { readFile } = _promises;
|
|
15
|
+
export const getDocsState = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const mintJsonPath = join(CMD_EXEC_PATH, 'mint.json');
|
|
17
|
+
const mintJsonFileContent = yield readFile(mintJsonPath, 'utf8');
|
|
18
|
+
const validationResults = yield validateMintJson(mintJsonFileContent);
|
|
19
|
+
const { openApiFiles } = yield categorizeFilePaths(CMD_EXEC_PATH);
|
|
20
|
+
return yield generateOpenApiAnchorsOrTabs(validationResults.data, openApiFiles, CLIENT_PATH);
|
|
21
|
+
});
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { findAndRemoveImports, hasImports, getFileCategory, openApiCheck } from '@mintlify/common';
|
|
11
|
-
import { createPage, preparseMdx,
|
|
11
|
+
import { createPage, preparseMdx, writeMintConfigFile } from '@mintlify/prebuild';
|
|
12
12
|
import Chalk from 'chalk';
|
|
13
13
|
import chokidar from 'chokidar';
|
|
14
14
|
import { promises as _promises } from 'fs';
|
|
@@ -18,6 +18,7 @@ import yaml from 'js-yaml';
|
|
|
18
18
|
import pathUtil from 'path';
|
|
19
19
|
import { CMD_EXEC_PATH, NEXT_PROPS_PATH, NEXT_PUBLIC_PATH, CLIENT_PATH } from '../../constants.js';
|
|
20
20
|
import { generatePagesWithImports } from './generatePagesWithImports.js';
|
|
21
|
+
import { getDocsState } from './getDocsState.js';
|
|
21
22
|
import { resolveAllImports } from './resolveAllImports.js';
|
|
22
23
|
import { updateGeneratedNav, updateOpenApiFiles } from './update.js';
|
|
23
24
|
import { isFileSizeValid } from './utils.js';
|
|
@@ -170,7 +171,6 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
|
|
|
170
171
|
const potentialCategory = getFileCategory(filename);
|
|
171
172
|
const targetPath = getTargetPath(potentialCategory, filename);
|
|
172
173
|
let regenerateNav = false;
|
|
173
|
-
let pagesAcc = {};
|
|
174
174
|
let category = potentialCategory === 'potentialYamlOpenApiSpec' ||
|
|
175
175
|
potentialCategory === 'potentialJsonOpenApiSpec'
|
|
176
176
|
? 'staticFile'
|
|
@@ -208,13 +208,9 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
|
|
|
208
208
|
case 'mintConfig':
|
|
209
209
|
regenerateNav = true;
|
|
210
210
|
try {
|
|
211
|
-
const
|
|
212
|
-
const validationResults = yield validateMintJson(mintJsonFileContent);
|
|
213
|
-
const { openApiFiles } = yield categorizeFilePaths(CMD_EXEC_PATH);
|
|
214
|
-
const { mintConfig, pagesAcc: pagesAccFromGeneratedPages, openApiFiles: newOpenApiFiles, } = yield generateOpenApiAnchorsOrTabs(validationResults.data, openApiFiles, CLIENT_PATH);
|
|
215
|
-
pagesAcc = pagesAccFromGeneratedPages;
|
|
211
|
+
const { mintConfig, openApiFiles } = yield getDocsState();
|
|
216
212
|
yield writeMintConfigFile(mintConfig, CLIENT_PATH);
|
|
217
|
-
yield updateOpenApiFiles(
|
|
213
|
+
yield updateOpenApiFiles(openApiFiles);
|
|
218
214
|
}
|
|
219
215
|
catch (err) {
|
|
220
216
|
console.error(err);
|
|
@@ -250,7 +246,7 @@ const onUpdateEvent = (filename, callback) => __awaiter(void 0, void 0, void 0,
|
|
|
250
246
|
}
|
|
251
247
|
if (regenerateNav) {
|
|
252
248
|
// TODO: Instead of re-generating the entire nav, optimize by just updating the specific page that changed.
|
|
253
|
-
yield updateGeneratedNav(
|
|
249
|
+
yield updateGeneratedNav();
|
|
254
250
|
}
|
|
255
251
|
callback();
|
|
256
252
|
return category;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const updateGeneratedNav: (
|
|
1
|
+
import { OpenApiFile } from '@mintlify/models';
|
|
2
|
+
export declare const updateGeneratedNav: () => Promise<void>;
|
|
3
3
|
export declare const updateOpenApiFiles: (providedOpenApiFiles?: OpenApiFile[]) => Promise<void>;
|
|
@@ -12,7 +12,9 @@ import fse from 'fs-extra';
|
|
|
12
12
|
import { join } from 'path';
|
|
13
13
|
import { CLIENT_PATH, CMD_EXEC_PATH } from '../../constants.js';
|
|
14
14
|
import { generateNav } from './generate.js';
|
|
15
|
-
|
|
15
|
+
import { getDocsState } from './getDocsState.js';
|
|
16
|
+
export const updateGeneratedNav = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const { pagesAcc } = yield getDocsState();
|
|
16
18
|
const generatedNav = yield generateNav(pagesAcc);
|
|
17
19
|
const targetPath = join(CLIENT_PATH, 'src', '_props', 'generatedNav.json');
|
|
18
20
|
yield fse.outputFile(targetPath, JSON.stringify(generatedNav, null, 2), {
|