@mintlify/cli 4.0.1141 → 4.0.1143

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/bin/update.js CHANGED
@@ -8,18 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { SpinnerLog, SuccessLog, ErrorLog, addLog, addErrorLog, clearLogs, } from '@mintlify/previewing';
11
+ import { SpinnerLog, SuccessLog, ErrorLog, addLog, addErrorLog, clearLogs, getLatestClientVersion, downloadTargetMint, getClientVersion, } from '@mintlify/previewing';
12
12
  import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
13
13
  export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packageName }) {
14
14
  addLog(_jsx(SpinnerLog, { message: "updating..." }));
15
- const { cli: existingCliVersion } = getVersions();
15
+ const { cli: existingCliVersion } = getVersions(packageName);
16
16
  const latestCliVersion = getLatestCliVersion(packageName);
17
17
  const isUpToDate = existingCliVersion && latestCliVersion && latestCliVersion.trim() === existingCliVersion.trim();
18
- if (isUpToDate) {
19
- addLog(_jsx(SuccessLog, { message: "already up to date" }));
20
- return;
21
- }
22
- if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
18
+ if (!isUpToDate && existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
23
19
  const packageManager = yield detectPackageManager({ packageName });
24
20
  try {
25
21
  clearLogs();
@@ -38,5 +34,31 @@ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packa
38
34
  }
39
35
  }
40
36
  clearLogs();
41
- addLog(_jsx(SuccessLog, { message: `updated ${packageName} to the latest version: ${latestCliVersion}` }));
37
+ addLog(_jsx(SpinnerLog, { message: "updating client..." }));
38
+ let clientUpdated = false;
39
+ const latestClientVersion = yield getLatestClientVersion();
40
+ if (latestClientVersion) {
41
+ const existingClientVersion = getClientVersion().trim();
42
+ if (existingClientVersion !== latestClientVersion.trim()) {
43
+ try {
44
+ yield downloadTargetMint({
45
+ targetVersion: latestClientVersion,
46
+ existingVersion: existingClientVersion === 'none' ? null : existingClientVersion,
47
+ });
48
+ clientUpdated = true;
49
+ }
50
+ catch (err) {
51
+ const errorMessage = err instanceof Error ? err.message : String(err);
52
+ addErrorLog(_jsx(ErrorLog, { message: `Failed to update client: ${errorMessage}` }));
53
+ return;
54
+ }
55
+ }
56
+ }
57
+ clearLogs();
58
+ if (isUpToDate && !clientUpdated) {
59
+ addLog(_jsx(SuccessLog, { message: "already up to date" }));
60
+ }
61
+ else {
62
+ addLog(_jsx(SuccessLog, { message: `updated ${packageName} to the latest version: ${latestCliVersion}` }));
63
+ }
42
64
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1141",
3
+ "version": "4.0.1143",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -45,11 +45,12 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "7.9.0",
48
- "@mintlify/common": "1.0.872",
49
- "@mintlify/link-rot": "3.0.1050",
50
- "@mintlify/prebuild": "1.0.1015",
51
- "@mintlify/previewing": "4.0.1076",
52
- "@mintlify/validation": "0.1.683",
48
+ "@mintlify/common": "1.0.873",
49
+ "@mintlify/link-rot": "3.0.1051",
50
+ "@mintlify/models": "0.0.301",
51
+ "@mintlify/prebuild": "1.0.1016",
52
+ "@mintlify/previewing": "4.0.1077",
53
+ "@mintlify/validation": "0.1.684",
53
54
  "adm-zip": "0.5.16",
54
55
  "chalk": "5.2.0",
55
56
  "color": "4.2.3",
@@ -93,5 +94,5 @@
93
94
  "vitest": "2.1.9",
94
95
  "vitest-mock-process": "1.0.4"
95
96
  },
96
- "gitHead": "d882bbf0e323d546678aa31f4feaa7663c2f1739"
97
+ "gitHead": "013911b92fc2916f1ddadcc42ff5397b5ee4d1e7"
97
98
  }
package/src/cli.tsx CHANGED
@@ -111,7 +111,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
111
111
  async (argv) => {
112
112
  await autoUpgradeIfNeeded();
113
113
  const port = await checkPort(argv);
114
- const { cli: cliVersion } = getVersions();
114
+ const { cli: cliVersion } = getVersions(packageName);
115
115
  let accessToken: string | undefined;
116
116
  let subdomain: string | undefined;
117
117
  try {
@@ -183,7 +183,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
183
183
  }
184
184
  }
185
185
 
186
- const { cli: cliVersion } = getVersions();
186
+ const { cli: cliVersion } = getVersions(packageName);
187
187
  await validateBuild({
188
188
  ...argv,
189
189
  packageName,
@@ -218,7 +218,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
218
218
  .example('mintlify export', 'export as export.zip')
219
219
  .example('mintlify export --output docs.zip', 'export to custom filename'),
220
220
  async (argv) => {
221
- const { cli: cliVersion } = getVersions();
221
+ const { cli: cliVersion } = getVersions(packageName);
222
222
  await exportSite({
223
223
  ...argv,
224
224
  packageName,
@@ -519,7 +519,7 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
519
519
  'Display the current version of the CLI and client',
520
520
  () => undefined,
521
521
  async () => {
522
- const { cli, client } = getVersions();
522
+ const { cli, client } = getVersions(packageName);
523
523
  addLog(
524
524
  <Text>
525
525
  <Text bold color="green">
package/src/helpers.tsx CHANGED
@@ -19,6 +19,7 @@ import yaml from 'js-yaml';
19
19
  import { exec, execSync } from 'node:child_process';
20
20
  import { readFileSync } from 'node:fs';
21
21
  import fs from 'node:fs/promises';
22
+ import { createRequire } from 'node:module';
22
23
  import { fileURLToPath } from 'node:url';
23
24
  import { promisify } from 'node:util';
24
25
  import path from 'path';
@@ -129,47 +130,46 @@ export const upgradeConfig = async () => {
129
130
  }
130
131
  };
131
132
 
132
- // Resolve the CLI's own package.json via `import.meta.url` so the version is
133
- // always the one shipped with this package, regardless of cwd. See #7121.
134
- const CLI_PACKAGE_JSON_PATH = (() => {
133
+ const require = createRequire(import.meta.url);
134
+
135
+ const isRunningFromLinkedBuild = (): boolean => {
135
136
  try {
136
- return fileURLToPath(new URL('../package.json', import.meta.url));
137
+ const thisFile = fileURLToPath(import.meta.url);
138
+ return !thisFile.split(path.sep).includes('node_modules');
137
139
  } catch {
138
- return undefined;
140
+ return false;
139
141
  }
140
- })();
142
+ };
141
143
 
142
- const readCliPackageVersion = (): string | undefined => {
143
- if (!CLI_PACKAGE_JSON_PATH) return undefined;
144
+ const readPackageVersion = (packageName: string): string | undefined => {
144
145
  try {
145
- const pkg = JSON.parse(readFileSync(CLI_PACKAGE_JSON_PATH, 'utf8')) as { version?: string };
146
+ const pkgPath = require.resolve(`${packageName}/package.json`);
147
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };
146
148
  return typeof pkg.version === 'string' ? pkg.version : undefined;
147
149
  } catch {
148
150
  return undefined;
149
151
  }
150
152
  };
151
153
 
152
- // Outside `node_modules` means `yarn dev` or `npm link`: treat as linked. See #7121.
153
- const isRunningFromLinkedBuild = (): boolean => {
154
- if (!CLI_PACKAGE_JSON_PATH) return false;
155
- return !CLI_PACKAGE_JSON_PATH.split(path.sep).includes('node_modules');
156
- };
157
-
158
- export const getCliVersion = (): string | undefined => {
154
+ export const getCliVersion = (
155
+ packageName: string = process.env.MINTLIFY_PACKAGE_NAME ?? 'mint'
156
+ ): string | undefined => {
159
157
  if (process.env.CLI_TEST_MODE === 'true') {
160
158
  return 'test-cli';
161
159
  }
162
160
  if (isRunningFromLinkedBuild()) {
163
161
  return LOCAL_LINKED_CLI_VERSION;
164
162
  }
165
- return readCliPackageVersion();
163
+ return readPackageVersion(packageName);
166
164
  };
167
165
 
168
- export const getVersions = (): {
166
+ export const getVersions = (
167
+ packageName: string = process.env.MINTLIFY_PACKAGE_NAME ?? 'mint'
168
+ ): {
169
169
  cli: string | undefined;
170
170
  client: string | undefined;
171
171
  } => {
172
- const cli = getCliVersion();
172
+ const cli = getCliVersion(packageName);
173
173
  const client = getClientVersion().trim();
174
174
  return { cli, client };
175
175
  };
@@ -8,7 +8,7 @@ import { getAccessToken } from '../keyring.js';
8
8
  import { getCliSubdomains } from '../status.js';
9
9
  import { trackEvent } from '../telemetry/track.js';
10
10
  import { fetchScoreBySlug, resolveScoreForUrl } from './client.js';
11
- import type { Check, ScoreResponse } from './types.js';
11
+ import type { Check, CliCheckStatus, ScoreResponse } from './types.js';
12
12
 
13
13
  type OutputFormat = 'table' | 'plain' | 'json';
14
14
 
@@ -21,13 +21,33 @@ function resolveFormat(argv: { format?: string }): OutputFormat {
21
21
  return 'table';
22
22
  }
23
23
 
24
- function statusIcon(pass: boolean): string {
25
- return pass ? chalk.green('✓') : chalk.red('✗');
24
+ function statusIcon(status: CliCheckStatus): string {
25
+ switch (status) {
26
+ case 'pass':
27
+ return chalk.green('✓');
28
+ case 'warn':
29
+ return chalk.yellow('⚠');
30
+ case 'skip':
31
+ return chalk.dim('○');
32
+ case 'fail':
33
+ case 'error':
34
+ return chalk.red('✗');
35
+ default: {
36
+ const _exhaustive: never = status;
37
+ void _exhaustive;
38
+ return chalk.dim('?');
39
+ }
40
+ }
41
+ }
42
+
43
+ function plainStatusLabel(status: CliCheckStatus): string {
44
+ return status.toUpperCase();
26
45
  }
27
46
 
28
47
  function formatCheckName(name: string): string {
29
48
  return name
30
- .replace(/([A-Z])/g, ' $1')
49
+ .replace(/[-_]+/g, ' ')
50
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
31
51
  .replace(/^./, (c) => c.toUpperCase())
32
52
  .trim();
33
53
  }
@@ -36,7 +56,7 @@ function renderChecks(checks: Check[], indent = 0): string[] {
36
56
  const lines: string[] = [];
37
57
  const pad = ' '.repeat(indent + 1);
38
58
  for (const check of checks) {
39
- lines.push(`${pad}${statusIcon(check.pass)} ${formatCheckName(check.name)}`);
59
+ lines.push(`${pad}${statusIcon(check.status)} ${formatCheckName(check.name)}`);
40
60
  if (check.children && check.children.length > 0) {
41
61
  lines.push(...renderChecks(check.children, indent + 1));
42
62
  }
@@ -47,7 +67,7 @@ function renderChecks(checks: Check[], indent = 0): string[] {
47
67
  function renderPlain(checks: Check[], prefix = ''): string[] {
48
68
  const lines: string[] = [];
49
69
  for (const check of checks) {
50
- lines.push(`${prefix}${check.pass ? 'PASS' : 'FAIL'}\t${check.name}`);
70
+ lines.push(`${prefix}${plainStatusLabel(check.status)}\t${check.name}`);
51
71
  if (check.children && check.children.length > 0) {
52
72
  lines.push(...renderPlain(check.children, prefix + ' '));
53
73
  }
@@ -1,26 +1,15 @@
1
- export type Check = {
2
- name: string;
3
- pass: boolean;
4
- metadata?: Record<string, unknown>;
5
- children?: Check[];
6
- };
7
-
8
- export type ResolveStatus = 'ready' | 'stale_refresh_queued' | 'queued';
9
-
10
- export type ResolveResult = {
11
- canonicalUrl: string;
12
- slug: string;
13
- status: ResolveStatus;
14
- trackedSiteId: string;
15
- };
16
-
17
- export type ScoreResponse = {
18
- canonicalUrl: string;
19
- checks: Check[];
20
- computedAt: string;
21
- name: string;
22
- overallScore: number;
23
- passedChecks: number;
24
- slug: string;
25
- totalChecks: number;
26
- };
1
+ // These types are defined in `@mintlify/models/src/types/cliScoreResponse.ts`.
2
+ // The server (mintlify/server) is the source of truth for this contract — it
3
+ // implements the response shape in `agentReadinessScore.controller.ts` →
4
+ // `getCliSiteScore`. Do not redefine the shape locally; update the shared
5
+ // package (and bump the dependency in both repos) if you need to change it.
6
+ export type {
7
+ CliCheckStatus,
8
+ CliGrade,
9
+ CliScoreCheck as Check,
10
+ CliScorePendingResponse,
11
+ CliScoreResolveResponse as ResolveResult,
12
+ CliScoreResolveStatus as ResolveStatus,
13
+ CliScoreResponse as ScoreResponse,
14
+ CliScoreResponseStatus,
15
+ } from '@mintlify/models';
package/src/update.tsx CHANGED
@@ -5,23 +5,21 @@ import {
5
5
  addLog,
6
6
  addErrorLog,
7
7
  clearLogs,
8
+ getLatestClientVersion,
9
+ downloadTargetMint,
10
+ getClientVersion,
8
11
  } from '@mintlify/previewing';
9
12
 
10
13
  import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
11
14
 
12
15
  export const update = async ({ packageName }: { packageName: string }) => {
13
16
  addLog(<SpinnerLog message="updating..." />);
14
- const { cli: existingCliVersion } = getVersions();
17
+ const { cli: existingCliVersion } = getVersions(packageName);
15
18
  const latestCliVersion = getLatestCliVersion(packageName);
16
19
  const isUpToDate =
17
20
  existingCliVersion && latestCliVersion && latestCliVersion.trim() === existingCliVersion.trim();
18
21
 
19
- if (isUpToDate) {
20
- addLog(<SuccessLog message="already up to date" />);
21
- return;
22
- }
23
-
24
- if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
22
+ if (!isUpToDate && existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
25
23
  const packageManager = await detectPackageManager({ packageName });
26
24
  try {
27
25
  clearLogs();
@@ -44,7 +42,32 @@ export const update = async ({ packageName }: { packageName: string }) => {
44
42
  }
45
43
 
46
44
  clearLogs();
47
- addLog(
48
- <SuccessLog message={`updated ${packageName} to the latest version: ${latestCliVersion}`} />
49
- );
45
+ addLog(<SpinnerLog message="updating client..." />);
46
+ let clientUpdated = false;
47
+ const latestClientVersion = await getLatestClientVersion();
48
+ if (latestClientVersion) {
49
+ const existingClientVersion = getClientVersion().trim();
50
+ if (existingClientVersion !== latestClientVersion.trim()) {
51
+ try {
52
+ await downloadTargetMint({
53
+ targetVersion: latestClientVersion,
54
+ existingVersion: existingClientVersion === 'none' ? null : existingClientVersion,
55
+ });
56
+ clientUpdated = true;
57
+ } catch (err) {
58
+ const errorMessage = err instanceof Error ? err.message : String(err);
59
+ addErrorLog(<ErrorLog message={`Failed to update client: ${errorMessage}`} />);
60
+ return;
61
+ }
62
+ }
63
+ }
64
+
65
+ clearLogs();
66
+ if (isUpToDate && !clientUpdated) {
67
+ addLog(<SuccessLog message="already up to date" />);
68
+ } else {
69
+ addLog(
70
+ <SuccessLog message={`updated ${packageName} to the latest version: ${latestCliVersion}`} />
71
+ );
72
+ }
50
73
  };