@mintlify/previewing 4.0.562 → 4.0.564
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/__tests__/dev.test.js +40 -26
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/local-preview/index.js +16 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -52,9 +52,10 @@ const runMock = vi.mocked(run);
|
|
|
52
52
|
const buildLoggerMock = vi.mocked(utils.buildLogger);
|
|
53
53
|
const processExitMock = mockProcessExit();
|
|
54
54
|
const downloadTargetMintMock = vi.mocked(downloadTargetMint);
|
|
55
|
-
const
|
|
55
|
+
const defaultYargs = {
|
|
56
56
|
_: [],
|
|
57
57
|
$0: '',
|
|
58
|
+
packageName: 'mintlify',
|
|
58
59
|
};
|
|
59
60
|
describe('dev', () => {
|
|
60
61
|
beforeEach(() => {
|
|
@@ -65,7 +66,7 @@ describe('dev', () => {
|
|
|
65
66
|
process.chdir = originalChdir;
|
|
66
67
|
});
|
|
67
68
|
it('happy path', async () => {
|
|
68
|
-
await dev(
|
|
69
|
+
await dev(defaultYargs);
|
|
69
70
|
expect(buildLoggerMock).toHaveBeenCalledWith('Preparing local Mintlify instance...');
|
|
70
71
|
expect(prebuildMock).toHaveBeenCalled();
|
|
71
72
|
expect(buildLoggerMock().succeed).toHaveBeenCalledWith('Local Mintlify instance is ready. Launching your site...');
|
|
@@ -74,52 +75,65 @@ describe('dev', () => {
|
|
|
74
75
|
it('prebuild fails', async () => {
|
|
75
76
|
const errorText = 'Some OpenAPI or docs.json schema error';
|
|
76
77
|
prebuildMock.mockRejectedValueOnce(new Error(errorText));
|
|
77
|
-
await dev(
|
|
78
|
+
await dev(defaultYargs);
|
|
78
79
|
expect(buildLoggerMock).toHaveBeenCalledWith('Preparing local Mintlify instance...');
|
|
79
80
|
expect(buildLoggerMock().fail).toHaveBeenCalledWith(errorText);
|
|
80
81
|
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
81
82
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
afterEach(() => {
|
|
89
|
-
process.chdir = originalChdir;
|
|
83
|
+
it('fails if no existing client version and no internet', async () => {
|
|
84
|
+
vi.mocked(isOnline).mockResolvedValueOnce(false);
|
|
85
|
+
vi.mocked(fse.pathExists).mockResolvedValueOnce();
|
|
86
|
+
await dev(defaultYargs).catch(() => { });
|
|
87
|
+
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
88
|
+
expect(buildLoggerMock().fail).toHaveBeenCalledWith('Running mintlify dev after updating requires an internet connection.');
|
|
90
89
|
});
|
|
91
|
-
it('fails if no existing version', async () => {
|
|
90
|
+
it('fails if no existing client version and no internet - mint command', async () => {
|
|
92
91
|
vi.mocked(isOnline).mockResolvedValueOnce(false);
|
|
93
92
|
vi.mocked(fse.pathExists).mockResolvedValueOnce();
|
|
94
|
-
await dev(
|
|
93
|
+
await dev({ ...defaultYargs, packageName: 'mint' }).catch(() => { });
|
|
95
94
|
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
96
|
-
expect(buildLoggerMock().fail).toHaveBeenCalledWith('Running
|
|
95
|
+
expect(buildLoggerMock().fail).toHaveBeenCalledWith('Running mint dev after updating requires an internet connection.');
|
|
97
96
|
});
|
|
98
97
|
it('has existing version but fails to get targetMintVersion', async () => {
|
|
99
98
|
vi.mocked(isOnline).mockResolvedValueOnce(false);
|
|
100
99
|
vi.mocked(getTargetMintVersion).mockResolvedValueOnce(undefined);
|
|
101
|
-
await dev(
|
|
100
|
+
await dev(defaultYargs);
|
|
102
101
|
expect(buildLoggerMock().warn).toHaveBeenCalledWith('Failed to get latest Mintlify client version. Your current version is: 1.0.0, which may not be the latest Mintlify client version.');
|
|
103
102
|
expect(prebuildMock).toHaveBeenCalled();
|
|
104
103
|
expect(buildLoggerMock().succeed).toHaveBeenCalledWith('Local Mintlify instance is ready. Launching your site...');
|
|
105
104
|
expect(runMock).toHaveBeenCalled();
|
|
106
105
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
process.chdir = originalChdir;
|
|
106
|
+
it('downloads client with --client-version arg', async () => {
|
|
107
|
+
await dev({ ...defaultYargs, 'client-version': '1.0.3' });
|
|
108
|
+
expect(buildLoggerMock).toHaveBeenCalledWith('Preparing local Mintlify instance...');
|
|
109
|
+
expect(downloadTargetMintMock).toHaveBeenCalled();
|
|
110
|
+
expect(prebuildMock).toHaveBeenCalled();
|
|
111
|
+
expect(buildLoggerMock().succeed).toHaveBeenCalledWith('Local Mintlify instance is ready. Launching your site...');
|
|
112
|
+
expect(runMock).toHaveBeenCalled();
|
|
115
113
|
});
|
|
116
|
-
it('
|
|
117
|
-
vi.mocked(
|
|
118
|
-
await dev(
|
|
114
|
+
it('downloads client if no existing version', async () => {
|
|
115
|
+
vi.mocked(fse.pathExists).mockResolvedValueOnce();
|
|
116
|
+
await dev(defaultYargs);
|
|
119
117
|
expect(buildLoggerMock).toHaveBeenCalledWith('Preparing local Mintlify instance...');
|
|
120
118
|
expect(downloadTargetMintMock).toHaveBeenCalled();
|
|
121
119
|
expect(prebuildMock).toHaveBeenCalled();
|
|
122
120
|
expect(buildLoggerMock().succeed).toHaveBeenCalledWith('Local Mintlify instance is ready. Launching your site...');
|
|
123
121
|
expect(runMock).toHaveBeenCalled();
|
|
124
122
|
});
|
|
123
|
+
it('warns about update if target version is different from existing version', async () => {
|
|
124
|
+
vi.mocked(getTargetMintVersion).mockResolvedValueOnce('1.0.1');
|
|
125
|
+
await dev(defaultYargs);
|
|
126
|
+
expect(buildLoggerMock().warn).toHaveBeenCalledWith('An update is available. Run `mintlify update` to update to the latest version.');
|
|
127
|
+
expect(prebuildMock).toHaveBeenCalled();
|
|
128
|
+
expect(buildLoggerMock().succeed).toHaveBeenCalledWith('Local Mintlify instance is ready. Launching your site...');
|
|
129
|
+
expect(runMock).toHaveBeenCalled();
|
|
130
|
+
});
|
|
131
|
+
it('warns about update if target version is different from existing version - mint command', async () => {
|
|
132
|
+
vi.mocked(getTargetMintVersion).mockResolvedValueOnce('1.0.1');
|
|
133
|
+
await dev({ ...defaultYargs, packageName: 'mint' });
|
|
134
|
+
expect(buildLoggerMock().warn).toHaveBeenCalledWith('An update is available. Run `mint update` to update to the latest version.');
|
|
135
|
+
expect(prebuildMock).toHaveBeenCalled();
|
|
136
|
+
expect(buildLoggerMock().succeed).toHaveBeenCalledWith('Local Mintlify instance is ready. Launching your site...');
|
|
137
|
+
expect(runMock).toHaveBeenCalled();
|
|
138
|
+
});
|
|
125
139
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getTargetMintVersion, downloadTargetMint } from './local-preview/client.js';
|
|
1
2
|
import dev from './local-preview/index.js';
|
|
2
3
|
import { getClientVersion } from './util.js';
|
|
3
|
-
export { dev, getClientVersion };
|
|
4
|
+
export { dev, getClientVersion, getTargetMintVersion, downloadTargetMint };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getTargetMintVersion, downloadTargetMint } from './local-preview/client.js';
|
|
1
2
|
import dev from './local-preview/index.js';
|
|
2
3
|
import { getClientVersion } from './util.js';
|
|
3
|
-
export { dev, getClientVersion };
|
|
4
|
+
export { dev, getClientVersion, getTargetMintVersion, downloadTargetMint };
|
|
@@ -14,12 +14,13 @@ const dev = async (argv) => {
|
|
|
14
14
|
const hasInternet = await isOnline();
|
|
15
15
|
const localSchema = argv['local-schema'];
|
|
16
16
|
const clientVersion = argv['client-version'];
|
|
17
|
+
const packageName = argv.packageName;
|
|
17
18
|
await fse.ensureDir(DOT_MINTLIFY);
|
|
18
19
|
const versionString = (await pathExists(VERSION_PATH))
|
|
19
20
|
? fse.readFileSync(VERSION_PATH, 'utf8')
|
|
20
21
|
: null;
|
|
21
22
|
if (!versionString && !hasInternet) {
|
|
22
|
-
logger.fail(
|
|
23
|
+
logger.fail(`Running ${packageName} dev after updating requires an internet connection.`);
|
|
23
24
|
process.exit(1);
|
|
24
25
|
}
|
|
25
26
|
const targetMintVersion = await getTargetMintVersion(logger);
|
|
@@ -27,13 +28,20 @@ const dev = async (argv) => {
|
|
|
27
28
|
logger.stopAndPersist({ symbol: '✓' });
|
|
28
29
|
logger.warn(`Failed to get latest Mintlify client version. Your current version is: ${versionString?.trim()}, which may not be the latest Mintlify client version.`);
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
// update the client if the user has provided a version with --client-version
|
|
32
|
+
// or if there is no version and there is internet and the target version is available
|
|
33
|
+
if (clientVersion !== undefined || (!versionString && hasInternet && targetMintVersion)) {
|
|
34
|
+
const version = clientVersion ?? targetMintVersion;
|
|
35
|
+
if (version) {
|
|
36
|
+
await downloadTargetMint({
|
|
37
|
+
logger,
|
|
38
|
+
targetVersion: version,
|
|
39
|
+
existingVersion: versionString,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (versionString && targetMintVersion && versionString.trim() !== targetMintVersion.trim()) {
|
|
44
|
+
logger.warn(`An update is available. Run \`${packageName} update\` to update to the latest version.`);
|
|
37
45
|
}
|
|
38
46
|
// clear preexisting prebuild files
|
|
39
47
|
fse.emptyDirSync(NEXT_PUBLIC_PATH);
|