@mintlify/cli 4.0.646 → 4.0.648
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/CONTRIBUTING.md +0 -4
- package/__test__/update.test.ts +2 -135
- package/bin/cli.js +4 -10
- package/bin/constants.js +0 -2
- package/bin/helpers.js +3 -3
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/bin/update.js +11 -46
- package/package.json +7 -7
- package/src/cli.tsx +2 -12
- package/src/constants.ts +0 -2
- package/src/helpers.tsx +3 -2
- package/src/update.tsx +13 -62
- package/__test__/minVersion.test.ts +0 -73
package/CONTRIBUTING.md
CHANGED
|
@@ -43,7 +43,3 @@ If for some reason the release workflow is broken or we can't access AWS program
|
|
|
43
43
|
## Manually overriding the client version used locally
|
|
44
44
|
|
|
45
45
|
Run `mintlify dev --client-version x.x.xxxx` with the client version you would like to use and that version will be downloaded instead of the latest client version.
|
|
46
|
-
|
|
47
|
-
## Breaking changes
|
|
48
|
-
|
|
49
|
-
If cli or client contain breaking changes that require they are both updated together, change the MINIMUM_CLI_VERSION to make sure `mint dev` will silently update to a minimum viable CLI version.
|
package/__test__/update.test.ts
CHANGED
|
@@ -9,7 +9,6 @@ vi.mock('@mintlify/previewing', async () => {
|
|
|
9
9
|
return {
|
|
10
10
|
...originalModule,
|
|
11
11
|
getClientVersion: vi.fn(),
|
|
12
|
-
getTargetMintVersion: vi.fn(),
|
|
13
12
|
downloadTargetMint: vi.fn(),
|
|
14
13
|
};
|
|
15
14
|
});
|
|
@@ -39,58 +38,30 @@ describe('update', () => {
|
|
|
39
38
|
vi.resetAllMocks();
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
it('should update the cli
|
|
41
|
+
it('should update the cli successfully', async () => {
|
|
43
42
|
vi.mocked(getVersions).mockReturnValue({
|
|
44
43
|
cli: '1.0.0',
|
|
45
44
|
client: '1.0.0',
|
|
46
45
|
});
|
|
47
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('2.0.0');
|
|
48
46
|
vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
|
|
49
47
|
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
50
48
|
vi.mocked(previewing.downloadTargetMint).mockResolvedValue();
|
|
51
49
|
|
|
52
50
|
await update({ packageName: 'mintlify' });
|
|
53
51
|
|
|
54
|
-
expect(addLogSpy).toHaveBeenCalledTimes(
|
|
52
|
+
expect(addLogSpy).toHaveBeenCalledTimes(3);
|
|
55
53
|
expect(addLogSpy).toHaveBeenCalledWith(
|
|
56
54
|
expect.objectContaining({ props: { message: 'updating...' } })
|
|
57
55
|
);
|
|
58
56
|
expect(addLogSpy).toHaveBeenCalledWith(
|
|
59
57
|
expect.objectContaining({ props: { message: 'updating mintlify package...' } })
|
|
60
58
|
);
|
|
61
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
62
|
-
expect.objectContaining({ props: { message: 'updating mintlify client to 2.0.0...' } })
|
|
63
|
-
);
|
|
64
59
|
expect(addLogSpy).toHaveBeenCalledWith(
|
|
65
60
|
expect.objectContaining({
|
|
66
61
|
props: { message: 'updated mintlify to the latest version: 2.0.0' },
|
|
67
62
|
})
|
|
68
63
|
);
|
|
69
64
|
expect(execAsync).toHaveBeenCalledWith('npm install -g mintlify@latest --silent');
|
|
70
|
-
expect(previewing.downloadTargetMint).toHaveBeenCalledWith({
|
|
71
|
-
targetVersion: '2.0.0',
|
|
72
|
-
existingVersion: '1.0.0',
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should update the cli and client successfully - silently', async () => {
|
|
77
|
-
vi.mocked(getVersions).mockReturnValue({
|
|
78
|
-
cli: '1.0.0',
|
|
79
|
-
client: '1.0.0',
|
|
80
|
-
});
|
|
81
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('2.0.0');
|
|
82
|
-
vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
|
|
83
|
-
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
84
|
-
vi.mocked(previewing.downloadTargetMint).mockResolvedValue();
|
|
85
|
-
|
|
86
|
-
await update({ packageName: 'mintlify', silent: true });
|
|
87
|
-
|
|
88
|
-
expect(addLogSpy).not.toHaveBeenCalled();
|
|
89
|
-
expect(execAsync).toHaveBeenCalledWith('npm install -g mintlify@latest --silent');
|
|
90
|
-
expect(previewing.downloadTargetMint).toHaveBeenCalledWith({
|
|
91
|
-
targetVersion: '2.0.0',
|
|
92
|
-
existingVersion: '1.0.0',
|
|
93
|
-
});
|
|
94
65
|
});
|
|
95
66
|
|
|
96
67
|
it('should return when already up to date', async () => {
|
|
@@ -99,9 +70,7 @@ describe('update', () => {
|
|
|
99
70
|
client: '1.0.0',
|
|
100
71
|
});
|
|
101
72
|
vi.mocked(getLatestCliVersion).mockReturnValue('1.0.0');
|
|
102
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('1.0.0');
|
|
103
73
|
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
104
|
-
vi.mocked(previewing.downloadTargetMint).mockResolvedValue();
|
|
105
74
|
|
|
106
75
|
await update({ packageName: 'mintlify' });
|
|
107
76
|
|
|
@@ -113,83 +82,6 @@ describe('update', () => {
|
|
|
113
82
|
expect.objectContaining({ props: { message: 'already up to date' } })
|
|
114
83
|
);
|
|
115
84
|
expect(execAsync).not.toHaveBeenCalled();
|
|
116
|
-
expect(previewing.downloadTargetMint).not.toHaveBeenCalled();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should return when already up to date - silently', async () => {
|
|
120
|
-
vi.mocked(getVersions).mockReturnValue({
|
|
121
|
-
cli: '1.0.0',
|
|
122
|
-
client: '1.0.0',
|
|
123
|
-
});
|
|
124
|
-
vi.mocked(getLatestCliVersion).mockReturnValue('1.0.0');
|
|
125
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('1.0.0');
|
|
126
|
-
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
127
|
-
vi.mocked(previewing.downloadTargetMint).mockResolvedValue();
|
|
128
|
-
|
|
129
|
-
await update({ packageName: 'mintlify', silent: true });
|
|
130
|
-
|
|
131
|
-
expect(addLogSpy).not.toHaveBeenCalled();
|
|
132
|
-
expect(execAsync).not.toHaveBeenCalled();
|
|
133
|
-
expect(previewing.downloadTargetMint).not.toHaveBeenCalled();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('should only update cli if client version is up to date', async () => {
|
|
137
|
-
vi.mocked(getVersions).mockReturnValue({
|
|
138
|
-
cli: '1.0.0',
|
|
139
|
-
client: '2.0.0',
|
|
140
|
-
});
|
|
141
|
-
vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
|
|
142
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('2.0.0');
|
|
143
|
-
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
144
|
-
|
|
145
|
-
await update({ packageName: 'mintlify' });
|
|
146
|
-
|
|
147
|
-
expect(addLogSpy).toHaveBeenCalledTimes(3);
|
|
148
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
149
|
-
expect.objectContaining({ props: { message: 'updating...' } })
|
|
150
|
-
);
|
|
151
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
152
|
-
expect.objectContaining({ props: { message: 'updating mintlify package...' } })
|
|
153
|
-
);
|
|
154
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
155
|
-
expect.objectContaining({
|
|
156
|
-
props: { message: 'updated mintlify to the latest version: 2.0.0' },
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(execAsync).toHaveBeenCalledWith('npm install -g mintlify@latest --silent');
|
|
161
|
-
expect(previewing.downloadTargetMint).not.toHaveBeenCalled();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('should only update client if cli version is up to date', async () => {
|
|
165
|
-
vi.mocked(getVersions).mockReturnValue({
|
|
166
|
-
cli: '2.0.0',
|
|
167
|
-
client: '1.0.0',
|
|
168
|
-
});
|
|
169
|
-
vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
|
|
170
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('2.0.0');
|
|
171
|
-
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
172
|
-
|
|
173
|
-
await update({ packageName: 'mintlify' });
|
|
174
|
-
|
|
175
|
-
expect(addLogSpy).toHaveBeenCalledTimes(3);
|
|
176
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
177
|
-
expect.objectContaining({ props: { message: 'updating...' } })
|
|
178
|
-
);
|
|
179
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
180
|
-
expect.objectContaining({ props: { message: 'updating mintlify client to 2.0.0...' } })
|
|
181
|
-
);
|
|
182
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
183
|
-
expect.objectContaining({
|
|
184
|
-
props: { message: 'updated mintlify to the latest version: 2.0.0' },
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
expect(execAsync).not.toHaveBeenCalled();
|
|
189
|
-
expect(previewing.downloadTargetMint).toHaveBeenCalledWith({
|
|
190
|
-
targetVersion: '2.0.0',
|
|
191
|
-
existingVersion: '1.0.0',
|
|
192
|
-
});
|
|
193
85
|
});
|
|
194
86
|
|
|
195
87
|
it('should handle cli update failure', async () => {
|
|
@@ -198,7 +90,6 @@ describe('update', () => {
|
|
|
198
90
|
client: '1.0.0',
|
|
199
91
|
});
|
|
200
92
|
vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
|
|
201
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('2.0.0');
|
|
202
93
|
vi.mocked(execAsync).mockRejectedValue(new Error('Update failed'));
|
|
203
94
|
|
|
204
95
|
await update({ packageName: 'mintlify' });
|
|
@@ -214,28 +105,4 @@ describe('update', () => {
|
|
|
214
105
|
expect.objectContaining({ props: { message: 'failed to update mintlify@latest' } })
|
|
215
106
|
);
|
|
216
107
|
});
|
|
217
|
-
|
|
218
|
-
it('should handle client update failure', async () => {
|
|
219
|
-
vi.mocked(getVersions).mockReturnValue({
|
|
220
|
-
cli: '1.0.0',
|
|
221
|
-
client: '1.0.0',
|
|
222
|
-
});
|
|
223
|
-
vi.mocked(getLatestCliVersion).mockReturnValue('2.0.0');
|
|
224
|
-
vi.mocked(previewing.getTargetMintVersion).mockResolvedValue('2.0.0');
|
|
225
|
-
vi.mocked(execAsync).mockResolvedValue({ stdout: '', stderr: '' });
|
|
226
|
-
vi.mocked(previewing.downloadTargetMint).mockRejectedValue(new Error('Download failed'));
|
|
227
|
-
|
|
228
|
-
await update({ packageName: 'mintlify' });
|
|
229
|
-
|
|
230
|
-
expect(addLogSpy).toHaveBeenCalledTimes(4);
|
|
231
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
232
|
-
expect.objectContaining({ props: { message: 'updating...' } })
|
|
233
|
-
);
|
|
234
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
235
|
-
expect.objectContaining({ props: { message: 'updating mintlify client to 2.0.0...' } })
|
|
236
|
-
);
|
|
237
|
-
expect(addLogSpy).toHaveBeenCalledWith(
|
|
238
|
-
expect.objectContaining({ props: { message: 'failed to update mintlify client to 2.0.0' } })
|
|
239
|
-
);
|
|
240
|
-
});
|
|
241
108
|
});
|
package/bin/cli.js
CHANGED
|
@@ -13,11 +13,9 @@ import { getBrokenInternalLinks, renameFilesAndUpdateLinksInContent } from '@min
|
|
|
13
13
|
import { addLog, dev, ErrorLog, SpinnerLog, SuccessLog, Logs, clearLogs, BrokenLinksLog, WarningLog, } from '@mintlify/previewing';
|
|
14
14
|
import { render, Text } from 'ink';
|
|
15
15
|
import path from 'path';
|
|
16
|
-
import semver from 'semver';
|
|
17
16
|
import yargs from 'yargs';
|
|
18
17
|
import { hideBin } from 'yargs/helpers';
|
|
19
|
-
import {
|
|
20
|
-
import { checkPort, checkForMintJson, checkNodeVersion, upgradeConfig, checkForDocsJson, getCliVersion, getVersions, suppressConsoleWarnings, terminate, readLocalOpenApiFile, } from './helpers.js';
|
|
18
|
+
import { checkPort, checkForMintJson, checkNodeVersion, upgradeConfig, checkForDocsJson, getVersions, suppressConsoleWarnings, terminate, readLocalOpenApiFile, } from './helpers.js';
|
|
21
19
|
import { update } from './update.js';
|
|
22
20
|
export const cli = ({ packageName = 'mint' }) => {
|
|
23
21
|
render(_jsx(Logs, {}));
|
|
@@ -51,15 +49,11 @@ export const cli = ({ packageName = 'mint' }) => {
|
|
|
51
49
|
.example('mintlify dev', 'run with default settings (opens in browser)')
|
|
52
50
|
.example('mintlify dev --no-open', 'run without opening in browser'), (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
51
|
const port = yield checkPort(argv);
|
|
54
|
-
const cliVersion =
|
|
55
|
-
if (cliVersion &&
|
|
56
|
-
cliVersion !== LOCAL_LINKED_VERSION &&
|
|
57
|
-
semver.lt(cliVersion, MINIMUM_CLI_VERSION)) {
|
|
58
|
-
yield update({ packageName, silent: true });
|
|
59
|
-
}
|
|
52
|
+
const { cli: cliVersion } = getVersions();
|
|
60
53
|
if (port != undefined) {
|
|
61
54
|
yield dev(Object.assign(Object.assign({}, argv), { port,
|
|
62
|
-
packageName,
|
|
55
|
+
packageName,
|
|
56
|
+
cliVersion }));
|
|
63
57
|
}
|
|
64
58
|
else {
|
|
65
59
|
addLog(_jsx(ErrorLog, { message: "no available port found" }));
|
package/bin/constants.js
CHANGED
package/bin/helpers.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { getConfigPath } from '@mintlify/prebuild';
|
|
12
12
|
import { MintConfigUpdater } from '@mintlify/prebuild';
|
|
13
|
-
import { addLog, ErrorLog, getClientVersion, SuccessLog, InfoLog, SpinnerLog, removeLastLog, } from '@mintlify/previewing';
|
|
13
|
+
import { addLog, ErrorLog, getClientVersion, SuccessLog, InfoLog, SpinnerLog, removeLastLog, LOCAL_LINKED_CLI_VERSION, } from '@mintlify/previewing';
|
|
14
14
|
import { upgradeToDocsConfig } from '@mintlify/validation';
|
|
15
15
|
import detect from 'detect-port';
|
|
16
16
|
import fse from 'fs-extra';
|
|
@@ -21,7 +21,7 @@ import { exec, execSync } from 'node:child_process';
|
|
|
21
21
|
import { promisify } from 'node:util';
|
|
22
22
|
import path from 'path';
|
|
23
23
|
import yargs from 'yargs';
|
|
24
|
-
import { CMD_EXEC_PATH
|
|
24
|
+
import { CMD_EXEC_PATH } from './constants.js';
|
|
25
25
|
export const checkPort = (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
const initialPort = typeof argv.port === 'number' ? argv.port : 3000;
|
|
27
27
|
if (initialPort === (yield detect(initialPort)))
|
|
@@ -100,7 +100,7 @@ export const getCliVersion = () => {
|
|
|
100
100
|
// when running `npm link` the version is 'unknown'
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
102
102
|
if (version === 'unknown') {
|
|
103
|
-
version =
|
|
103
|
+
version = LOCAL_LINKED_CLI_VERSION;
|
|
104
104
|
}
|
|
105
105
|
return version;
|
|
106
106
|
};
|