@mintlify/cli 4.0.590 → 4.0.592
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/__test__/cli.test.ts +1 -11
- package/__test__/minVersion.test.ts +59 -0
- package/__test__/update.test.ts +4 -1
- package/__test__/utils.ts +11 -0
- package/bin/cli.js +19 -2
- package/bin/constants.js +2 -0
- package/bin/helpers.js +8 -6
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/bin/update.js +23 -8
- package/package.json +4 -3
- package/src/cli.ts +21 -0
- package/src/constants.ts +2 -0
- package/src/helpers.ts +8 -6
- package/src/update.ts +30 -8
package/bin/update.js
CHANGED
|
@@ -10,8 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { getTargetMintVersion, downloadTargetMint } from '@mintlify/previewing';
|
|
11
11
|
import { execSync } from 'node:child_process';
|
|
12
12
|
import { buildLogger, getLatestCliVersion, getVersions } from './helpers.js';
|
|
13
|
-
export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packageName }) {
|
|
14
|
-
|
|
13
|
+
export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packageName, silent, }) {
|
|
14
|
+
let logger = undefined;
|
|
15
|
+
if (!silent) {
|
|
16
|
+
logger = buildLogger(`Updating ${packageName} to the latest version...`);
|
|
17
|
+
}
|
|
15
18
|
const { cli: existingCliVersion, client: existingClientVersion } = getVersions();
|
|
16
19
|
const latestCliVersion = getLatestCliVersion(packageName);
|
|
17
20
|
const latestClientVersion = yield getTargetMintVersion(logger);
|
|
@@ -22,22 +25,30 @@ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packa
|
|
|
22
25
|
latestCliVersion.trim() === existingCliVersion.trim() &&
|
|
23
26
|
latestClientVersion.trim() === existingClientVersion.trim();
|
|
24
27
|
if (isUpToDate) {
|
|
25
|
-
|
|
28
|
+
if (!silent && logger) {
|
|
29
|
+
logger.succeed('Already up to date.');
|
|
30
|
+
}
|
|
26
31
|
return;
|
|
27
32
|
}
|
|
28
33
|
if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
|
|
29
34
|
try {
|
|
30
|
-
logger
|
|
35
|
+
if (logger) {
|
|
36
|
+
logger.text = `Updating ${packageName} package...`;
|
|
37
|
+
}
|
|
31
38
|
execSync(`npm install -g ${packageName}@latest --silent`);
|
|
32
39
|
}
|
|
33
40
|
catch (err) {
|
|
34
|
-
logger
|
|
41
|
+
if (logger) {
|
|
42
|
+
logger.fail(`Failed to update ${packageName}@latest`);
|
|
43
|
+
}
|
|
35
44
|
process.exit(1);
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
if (latestClientVersion && latestClientVersion !== existingClientVersion) {
|
|
39
48
|
try {
|
|
40
|
-
logger
|
|
49
|
+
if (logger) {
|
|
50
|
+
logger.text = `Updating Mintlify client to ${latestClientVersion}...`;
|
|
51
|
+
}
|
|
41
52
|
yield downloadTargetMint({
|
|
42
53
|
logger,
|
|
43
54
|
targetVersion: latestClientVersion,
|
|
@@ -45,9 +56,13 @@ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packa
|
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
58
|
catch (err) {
|
|
48
|
-
logger
|
|
59
|
+
if (logger) {
|
|
60
|
+
logger.fail(`Failed to update Mintlify client to ${latestClientVersion}`);
|
|
61
|
+
}
|
|
49
62
|
process.exit(1);
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
|
-
logger
|
|
65
|
+
if (logger) {
|
|
66
|
+
logger.succeed(`Updated ${packageName} to the latest version: ${latestCliVersion}`);
|
|
67
|
+
}
|
|
53
68
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.592",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@mintlify/link-rot": "3.0.543",
|
|
44
44
|
"@mintlify/models": "0.0.197",
|
|
45
45
|
"@mintlify/prebuild": "1.0.539",
|
|
46
|
-
"@mintlify/previewing": "4.0.
|
|
46
|
+
"@mintlify/previewing": "4.0.581",
|
|
47
47
|
"@mintlify/validation": "0.1.396",
|
|
48
48
|
"chalk": "^5.2.0",
|
|
49
49
|
"detect-port": "^1.5.1",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"inquirer": "^12.3.0",
|
|
52
52
|
"js-yaml": "^4.1.0",
|
|
53
53
|
"ora": "^6.1.2",
|
|
54
|
+
"semver": "^7.7.2",
|
|
54
55
|
"yargs": "^17.6.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"vitest": "^2.0.4",
|
|
72
73
|
"vitest-mock-process": "^1.0.4"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "a988d936874f604191e7eb5ef16bfbe27e1bfde2"
|
|
75
76
|
}
|
package/src/cli.ts
CHANGED
|
@@ -5,15 +5,18 @@ import Chalk from 'chalk';
|
|
|
5
5
|
import fs from 'fs/promises';
|
|
6
6
|
import yaml from 'js-yaml';
|
|
7
7
|
import path from 'path';
|
|
8
|
+
import semver from 'semver';
|
|
8
9
|
import yargs from 'yargs';
|
|
9
10
|
import { hideBin } from 'yargs/helpers';
|
|
10
11
|
|
|
12
|
+
import { LOCAL_LINKED_VERSION, MINIMUM_CLI_VERSION } from './constants.js';
|
|
11
13
|
import {
|
|
12
14
|
checkPort,
|
|
13
15
|
checkForMintJson,
|
|
14
16
|
checkNodeVersion,
|
|
15
17
|
upgradeConfig,
|
|
16
18
|
checkForDocsJson,
|
|
19
|
+
getCliVersion,
|
|
17
20
|
getVersions,
|
|
18
21
|
} from './helpers.js';
|
|
19
22
|
import { update } from './update.js';
|
|
@@ -47,13 +50,31 @@ export const cli = () =>
|
|
|
47
50
|
.example('mintlify dev', 'Run with default settings (opens in browser)')
|
|
48
51
|
.example('mintlify dev --no-open', 'Run without opening in browser'),
|
|
49
52
|
async (argv) => {
|
|
53
|
+
// Suppress deprecation warning for punycode
|
|
54
|
+
const originalConsoleError = console.error;
|
|
55
|
+
console.error = (...args) => {
|
|
56
|
+
const message = args.join(' ');
|
|
57
|
+
if (message.includes('DeprecationWarning')) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
originalConsoleError.apply(console, args);
|
|
61
|
+
};
|
|
50
62
|
const port = await checkPort(argv);
|
|
51
63
|
const packageName = process.argv[1]?.split('/').pop() ?? 'mintlify';
|
|
64
|
+
const cliVersion = getCliVersion();
|
|
65
|
+
if (
|
|
66
|
+
cliVersion &&
|
|
67
|
+
cliVersion !== LOCAL_LINKED_VERSION &&
|
|
68
|
+
semver.lt(cliVersion, MINIMUM_CLI_VERSION)
|
|
69
|
+
) {
|
|
70
|
+
await update({ packageName, silent: true });
|
|
71
|
+
}
|
|
52
72
|
if (port != undefined) {
|
|
53
73
|
await dev({
|
|
54
74
|
...argv,
|
|
55
75
|
port,
|
|
56
76
|
packageName,
|
|
77
|
+
cliVersion: cli,
|
|
57
78
|
});
|
|
58
79
|
} else {
|
|
59
80
|
console.error(`No available port found.`);
|
package/src/constants.ts
CHANGED
package/src/helpers.ts
CHANGED
|
@@ -13,7 +13,7 @@ import path from 'path';
|
|
|
13
13
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
14
14
|
import yargs from 'yargs';
|
|
15
15
|
|
|
16
|
-
import { CMD_EXEC_PATH } from './constants.js';
|
|
16
|
+
import { CMD_EXEC_PATH, LOCAL_LINKED_VERSION } from './constants.js';
|
|
17
17
|
|
|
18
18
|
export const checkPort = async (argv: ArgumentsCamelCase): Promise<number | undefined> => {
|
|
19
19
|
const initialPort = typeof argv.port === 'number' ? argv.port : 3000;
|
|
@@ -98,13 +98,18 @@ export const upgradeConfig = async () => {
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
const getCliVersion = (): string | undefined => {
|
|
101
|
+
export const getCliVersion = (): string | undefined => {
|
|
102
102
|
const y = yargs();
|
|
103
103
|
let version = undefined;
|
|
104
104
|
y.showVersion((s) => {
|
|
105
105
|
version = s;
|
|
106
106
|
return false;
|
|
107
107
|
});
|
|
108
|
+
// when running `npm link` the version is 'unknown'
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
110
|
+
if (version === 'unknown') {
|
|
111
|
+
version = LOCAL_LINKED_VERSION;
|
|
112
|
+
}
|
|
108
113
|
return version;
|
|
109
114
|
};
|
|
110
115
|
|
|
@@ -112,10 +117,7 @@ export const getVersions = (): {
|
|
|
112
117
|
cli: string | undefined;
|
|
113
118
|
client: string | undefined;
|
|
114
119
|
} => {
|
|
115
|
-
|
|
116
|
-
if (cli === 'unknown') {
|
|
117
|
-
cli = 'linked to local package';
|
|
118
|
-
}
|
|
120
|
+
const cli = getCliVersion();
|
|
119
121
|
const client = getClientVersion().trim();
|
|
120
122
|
return { cli, client };
|
|
121
123
|
};
|
package/src/update.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { getTargetMintVersion, downloadTargetMint } from '@mintlify/previewing';
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
|
+
import { Ora as OraType } from 'ora';
|
|
3
4
|
|
|
4
5
|
import { buildLogger, getLatestCliVersion, getVersions } from './helpers.js';
|
|
5
6
|
|
|
6
|
-
export const update = async ({
|
|
7
|
-
|
|
7
|
+
export const update = async ({
|
|
8
|
+
packageName,
|
|
9
|
+
silent,
|
|
10
|
+
}: {
|
|
11
|
+
packageName: string;
|
|
12
|
+
silent?: boolean;
|
|
13
|
+
}) => {
|
|
14
|
+
let logger: OraType | undefined = undefined;
|
|
15
|
+
if (!silent) {
|
|
16
|
+
logger = buildLogger(`Updating ${packageName} to the latest version...`);
|
|
17
|
+
}
|
|
8
18
|
const { cli: existingCliVersion, client: existingClientVersion } = getVersions();
|
|
9
19
|
const latestCliVersion = getLatestCliVersion(packageName);
|
|
10
20
|
const latestClientVersion = await getTargetMintVersion(logger);
|
|
@@ -17,33 +27,45 @@ export const update = async ({ packageName }: { packageName: string }) => {
|
|
|
17
27
|
latestClientVersion.trim() === existingClientVersion.trim();
|
|
18
28
|
|
|
19
29
|
if (isUpToDate) {
|
|
20
|
-
|
|
30
|
+
if (!silent && logger) {
|
|
31
|
+
logger.succeed('Already up to date.');
|
|
32
|
+
}
|
|
21
33
|
return;
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
|
|
25
37
|
try {
|
|
26
|
-
logger
|
|
38
|
+
if (logger) {
|
|
39
|
+
logger.text = `Updating ${packageName} package...`;
|
|
40
|
+
}
|
|
27
41
|
execSync(`npm install -g ${packageName}@latest --silent`);
|
|
28
42
|
} catch (err) {
|
|
29
|
-
logger
|
|
43
|
+
if (logger) {
|
|
44
|
+
logger.fail(`Failed to update ${packageName}@latest`);
|
|
45
|
+
}
|
|
30
46
|
process.exit(1);
|
|
31
47
|
}
|
|
32
48
|
}
|
|
33
49
|
|
|
34
50
|
if (latestClientVersion && latestClientVersion !== existingClientVersion) {
|
|
35
51
|
try {
|
|
36
|
-
logger
|
|
52
|
+
if (logger) {
|
|
53
|
+
logger.text = `Updating Mintlify client to ${latestClientVersion}...`;
|
|
54
|
+
}
|
|
37
55
|
await downloadTargetMint({
|
|
38
56
|
logger,
|
|
39
57
|
targetVersion: latestClientVersion,
|
|
40
58
|
existingVersion: existingClientVersion ?? null,
|
|
41
59
|
});
|
|
42
60
|
} catch (err) {
|
|
43
|
-
logger
|
|
61
|
+
if (logger) {
|
|
62
|
+
logger.fail(`Failed to update Mintlify client to ${latestClientVersion}`);
|
|
63
|
+
}
|
|
44
64
|
process.exit(1);
|
|
45
65
|
}
|
|
46
66
|
}
|
|
47
67
|
|
|
48
|
-
logger
|
|
68
|
+
if (logger) {
|
|
69
|
+
logger.succeed(`Updated ${packageName} to the latest version: ${latestCliVersion}`);
|
|
70
|
+
}
|
|
49
71
|
};
|