@mintlify/previewing 4.0.507 → 4.0.509
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
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const TARGET_MINT_VERSION = "v0.0.1154";
|
|
2
1
|
export declare const INSTALL_PATH: string;
|
|
3
2
|
export declare const HOME_DIR: string;
|
|
4
3
|
export declare const DOT_MINTLIFY: string;
|
|
@@ -10,7 +9,8 @@ export declare const NEXT_ROUTER_SERVER_PATH: string;
|
|
|
10
9
|
export declare const NEXT_CONFIG_PATH: string;
|
|
11
10
|
export declare const NEXT_PUBLIC_PATH: string;
|
|
12
11
|
export declare const NEXT_PROPS_PATH: string;
|
|
13
|
-
export declare const
|
|
12
|
+
export declare const TARGET_MINT_VERSION_URL = "https://mint-releases.b-cdn.net/mint-version.txt";
|
|
13
|
+
export declare const GET_TAR_URL: (version: string) => string;
|
|
14
14
|
export declare const TAR_PATH: string;
|
|
15
15
|
export declare const CMD_EXEC_PATH: string;
|
|
16
16
|
export declare const SUPPORTED_MEDIA_EXTENSIONS: string[];
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import * as url from 'url';
|
|
4
|
-
// Change this to bump to a newer version of mint's client
|
|
5
|
-
export const TARGET_MINT_VERSION = 'v0.0.1154';
|
|
6
4
|
// package installation location
|
|
7
5
|
export const INSTALL_PATH = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
6
|
export const HOME_DIR = os.homedir();
|
|
@@ -16,7 +14,8 @@ export const NEXT_ROUTER_SERVER_PATH = path.join(NEXT_DIST_SERVER_PATH, 'lib', '
|
|
|
16
14
|
export const NEXT_CONFIG_PATH = path.join(CLIENT_PATH, '.next', 'required-server-files.json');
|
|
17
15
|
export const NEXT_PUBLIC_PATH = path.join(CLIENT_PATH, 'public');
|
|
18
16
|
export const NEXT_PROPS_PATH = path.join(CLIENT_PATH, 'src', '_props');
|
|
19
|
-
export const
|
|
17
|
+
export const TARGET_MINT_VERSION_URL = 'https://mint-releases.b-cdn.net/mint-version.txt';
|
|
18
|
+
export const GET_TAR_URL = (version) => `https://mint-releases.b-cdn.net/mint-${version}.tar.gz`;
|
|
20
19
|
export const TAR_PATH = path.join(DOT_MINTLIFY, `mint.tar.gz`);
|
|
21
20
|
// command execution location
|
|
22
21
|
export const CMD_EXEC_PATH = process.cwd();
|
|
@@ -19,13 +19,28 @@ import { pipeline } from 'node:stream/promises';
|
|
|
19
19
|
import { pathToFileURL } from 'node:url';
|
|
20
20
|
import { Server as SocketServer } from 'socket.io';
|
|
21
21
|
import tar from 'tar';
|
|
22
|
-
import { CLIENT_PATH, DOT_MINTLIFY, CMD_EXEC_PATH,
|
|
22
|
+
import { CLIENT_PATH, DOT_MINTLIFY, CMD_EXEC_PATH, VERSION_PATH, MINT_PATH, NEXT_CONFIG_PATH, TAR_PATH, NEXT_PUBLIC_PATH, NEXT_PROPS_PATH, NEXT_SIDE_EFFECT_PATH, NEXT_ROUTER_SERVER_PATH, TARGET_MINT_VERSION_URL, GET_TAR_URL, } from '../constants.js';
|
|
23
23
|
import { buildLogger, maybeFixMissingWindowsEnvVar } from '../util.js';
|
|
24
24
|
import listener from './listener/index.js';
|
|
25
|
-
const
|
|
25
|
+
const getTargetMintVersion = (logger) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const hasInternet = yield isOnline();
|
|
27
|
+
if (!hasInternet) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const response = yield got(TARGET_MINT_VERSION_URL);
|
|
32
|
+
return response.body;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
logger.text = `Failed to fetch the latest Mintlify version: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const downloadTargetMint = (logger, targetMintVersion) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
40
|
fse.emptyDirSync(MINT_PATH);
|
|
27
41
|
logger.text = 'Downloading Mintlify framework...';
|
|
28
|
-
|
|
42
|
+
const tarUrl = GET_TAR_URL(targetMintVersion);
|
|
43
|
+
yield pipeline(got.stream(tarUrl), fse.createWriteStream(TAR_PATH));
|
|
29
44
|
logger.text = 'Extracting Mintlify framework...';
|
|
30
45
|
tar.x({
|
|
31
46
|
sync: true,
|
|
@@ -33,7 +48,7 @@ const downloadTargetMint = (logger) => __awaiter(void 0, void 0, void 0, functio
|
|
|
33
48
|
cwd: DOT_MINTLIFY,
|
|
34
49
|
});
|
|
35
50
|
fse.removeSync(TAR_PATH);
|
|
36
|
-
fse.writeFileSync(VERSION_PATH,
|
|
51
|
+
fse.writeFileSync(VERSION_PATH, targetMintVersion);
|
|
37
52
|
});
|
|
38
53
|
const dev = (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
54
|
// Note: We wait for specific text in the logger to be sure the server is ready when we e2e test the cli.
|
|
@@ -41,18 +56,25 @@ const dev = (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
41
56
|
// "- Preparing local Mintlify instance...\n✔ Local Mintlify instance is ready. Launching your site...\nYour local preview is available at http://localhost:3000\nPress Ctrl+C any time to stop the local preview."
|
|
42
57
|
// the test will fail/require an update.
|
|
43
58
|
const logger = buildLogger('Preparing local Mintlify instance...');
|
|
59
|
+
const hasInternet = yield isOnline();
|
|
44
60
|
yield fse.ensureDir(DOT_MINTLIFY);
|
|
45
61
|
const versionString = (yield pathExists(VERSION_PATH))
|
|
46
62
|
? fse.readFileSync(VERSION_PATH, 'utf8')
|
|
47
63
|
: null;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
if (!versionString && !hasInternet) {
|
|
65
|
+
logger.fail('Running mintlify dev afer updating requires an internet connection.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
const targetMintVersion = yield getTargetMintVersion(logger);
|
|
69
|
+
if (!targetMintVersion) {
|
|
70
|
+
logger.text =
|
|
71
|
+
'Failed to get latest Mintlify client version. Your current version is: ' +
|
|
72
|
+
versionString +
|
|
73
|
+
', which may not be the latest Mintlify client version.';
|
|
74
|
+
}
|
|
75
|
+
const shouldDownload = versionString !== targetMintVersion;
|
|
76
|
+
if (shouldDownload && hasInternet && targetMintVersion) {
|
|
77
|
+
yield downloadTargetMint(logger, targetMintVersion);
|
|
56
78
|
}
|
|
57
79
|
// clear preexisting prebuild files
|
|
58
80
|
fse.emptyDirSync(NEXT_PUBLIC_PATH);
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { hasImports, findAndRemoveImports, resolveAllImports } from '@mintlify/common';
|
|
10
|
+
import { hasImports, findAndRemoveImports, resolveAllImports, stringifyTree, } from '@mintlify/common';
|
|
11
11
|
import { preparseMdxTree, getFileListSync } from '@mintlify/prebuild';
|
|
12
12
|
import { promises as _promises } from 'fs';
|
|
13
13
|
import { outputFile } from 'fs-extra';
|
|
@@ -30,7 +30,7 @@ export const generatePagesWithImports = () => __awaiter(void 0, void 0, void 0,
|
|
|
30
30
|
fileWithImports: Object.assign(Object.assign({}, importsResponse), { filename: pageFilename }),
|
|
31
31
|
});
|
|
32
32
|
const targetPath = join(NEXT_PROPS_PATH, pageFilename);
|
|
33
|
-
yield outputFile(targetPath, content, {
|
|
33
|
+
yield outputFile(targetPath, stringifyTree(content), {
|
|
34
34
|
flag: 'w',
|
|
35
35
|
});
|
|
36
36
|
}
|