@mintlify/cli 4.0.645 → 4.0.647

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,33 +8,21 @@ 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 { getTargetMintVersion, downloadTargetMint, SpinnerLog, SuccessLog, ErrorLog, addLog, clearLogs, } from '@mintlify/previewing';
11
+ import { SpinnerLog, SuccessLog, ErrorLog, addLog, clearLogs } from '@mintlify/previewing';
12
12
  import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
13
- export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packageName, silent, }) {
14
- if (!silent) {
15
- addLog(_jsx(SpinnerLog, { message: "updating..." }));
16
- }
17
- const { cli: existingCliVersion, client: existingClientVersion } = getVersions();
13
+ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packageName }) {
14
+ addLog(_jsx(SpinnerLog, { message: "updating..." }));
15
+ const { cli: existingCliVersion } = getVersions();
18
16
  const latestCliVersion = getLatestCliVersion(packageName);
19
- const latestClientVersion = yield getTargetMintVersion();
20
- const isUpToDate = existingCliVersion &&
21
- existingClientVersion &&
22
- latestClientVersion &&
23
- latestCliVersion &&
24
- latestCliVersion.trim() === existingCliVersion.trim() &&
25
- latestClientVersion.trim() === existingClientVersion.trim();
17
+ const isUpToDate = existingCliVersion && latestCliVersion && latestCliVersion.trim() === existingCliVersion.trim();
26
18
  if (isUpToDate) {
27
- if (!silent) {
28
- addLog(_jsx(SuccessLog, { message: "already up to date" }));
29
- }
19
+ addLog(_jsx(SuccessLog, { message: "already up to date" }));
30
20
  return;
31
21
  }
32
22
  if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
33
23
  try {
34
- if (!silent) {
35
- clearLogs();
36
- addLog(_jsx(SpinnerLog, { message: `updating ${packageName} package...` }));
37
- }
24
+ clearLogs();
25
+ addLog(_jsx(SpinnerLog, { message: `updating ${packageName} package...` }));
38
26
  const packageManager = yield detectPackageManager({ packageName });
39
27
  if (packageManager === 'pnpm') {
40
28
  yield execAsync(`pnpm install -g ${packageName}@latest --silent`);
@@ -44,33 +32,10 @@ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packa
44
32
  }
45
33
  }
46
34
  catch (err) {
47
- if (!silent) {
48
- clearLogs();
49
- addLog(_jsx(ErrorLog, { message: `failed to update ${packageName}@latest` }));
50
- }
35
+ addLog(_jsx(ErrorLog, { message: `failed to update ${packageName}@latest` }));
51
36
  return;
52
37
  }
53
38
  }
54
- if (latestClientVersion && latestClientVersion !== existingClientVersion) {
55
- try {
56
- if (!silent) {
57
- addLog(_jsx(SpinnerLog, { message: `updating mintlify client to ${latestClientVersion}...` }));
58
- }
59
- yield downloadTargetMint({
60
- targetVersion: latestClientVersion,
61
- existingVersion: existingClientVersion !== null && existingClientVersion !== void 0 ? existingClientVersion : null,
62
- });
63
- }
64
- catch (err) {
65
- if (!silent) {
66
- clearLogs();
67
- addLog(_jsx(ErrorLog, { message: `failed to update mintlify client to ${latestClientVersion}` }));
68
- }
69
- return;
70
- }
71
- }
72
- if (!silent) {
73
- clearLogs();
74
- addLog(_jsx(SuccessLog, { message: `updated ${packageName} to the latest version: ${latestCliVersion}` }));
75
- }
39
+ clearLogs();
40
+ addLog(_jsx(SuccessLog, { message: `updated ${packageName} to the latest version: ${latestCliVersion}` }));
76
41
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.645",
3
+ "version": "4.0.647",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -39,11 +39,11 @@
39
39
  "format:check": "prettier . --check"
40
40
  },
41
41
  "dependencies": {
42
- "@mintlify/common": "1.0.466",
43
- "@mintlify/link-rot": "3.0.593",
42
+ "@mintlify/common": "1.0.467",
43
+ "@mintlify/link-rot": "3.0.595",
44
44
  "@mintlify/models": "0.0.214",
45
- "@mintlify/prebuild": "1.0.584",
46
- "@mintlify/previewing": "4.0.629",
45
+ "@mintlify/prebuild": "1.0.585",
46
+ "@mintlify/previewing": "4.0.631",
47
47
  "@mintlify/validation": "0.1.427",
48
48
  "chalk": "^5.2.0",
49
49
  "detect-port": "^1.5.1",
@@ -73,5 +73,5 @@
73
73
  "vitest": "^2.0.4",
74
74
  "vitest-mock-process": "^1.0.4"
75
75
  },
76
- "gitHead": "9ef67b5800722ae1e3f86bf0513c9605959652cd"
76
+ "gitHead": "e19c1e7ef7056401e779e4795c4162548f1d14c4"
77
77
  }
package/src/cli.tsx CHANGED
@@ -13,18 +13,15 @@ import {
13
13
  } 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
18
 
20
- import { LOCAL_LINKED_VERSION, MINIMUM_CLI_VERSION } from './constants.js';
21
19
  import {
22
20
  checkPort,
23
21
  checkForMintJson,
24
22
  checkNodeVersion,
25
23
  upgradeConfig,
26
24
  checkForDocsJson,
27
- getCliVersion,
28
25
  getVersions,
29
26
  suppressConsoleWarnings,
30
27
  terminate,
@@ -72,20 +69,13 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
72
69
  .example('mintlify dev --no-open', 'run without opening in browser'),
73
70
  async (argv) => {
74
71
  const port = await checkPort(argv);
75
- const cliVersion = getCliVersion();
76
- if (
77
- cliVersion &&
78
- cliVersion !== LOCAL_LINKED_VERSION &&
79
- semver.lt(cliVersion, MINIMUM_CLI_VERSION)
80
- ) {
81
- await update({ packageName, silent: true });
82
- }
72
+ const { cli: cliVersion } = getVersions();
83
73
  if (port != undefined) {
84
74
  await dev({
85
75
  ...argv,
86
76
  port,
87
77
  packageName,
88
- cliVersion: cli,
78
+ cliVersion,
89
79
  });
90
80
  } else {
91
81
  addLog(<ErrorLog message="no available port found" />);
package/src/constants.ts CHANGED
@@ -2,5 +2,3 @@ import os from 'os';
2
2
 
3
3
  export const HOME_DIR = os.homedir();
4
4
  export const CMD_EXEC_PATH = process.cwd();
5
- export const LOCAL_LINKED_VERSION = 'linked to local package';
6
- export const MINIMUM_CLI_VERSION = '4.1.90';
package/src/helpers.tsx CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  InfoLog,
9
9
  SpinnerLog,
10
10
  removeLastLog,
11
+ LOCAL_LINKED_CLI_VERSION,
11
12
  } from '@mintlify/previewing';
12
13
  import { upgradeToDocsConfig } from '@mintlify/validation';
13
14
  import detect from 'detect-port';
@@ -21,7 +22,7 @@ import path from 'path';
21
22
  import type { ArgumentsCamelCase } from 'yargs';
22
23
  import yargs from 'yargs';
23
24
 
24
- import { CMD_EXEC_PATH, LOCAL_LINKED_VERSION } from './constants.js';
25
+ import { CMD_EXEC_PATH } from './constants.js';
25
26
 
26
27
  export const checkPort = async (argv: ArgumentsCamelCase): Promise<number | undefined> => {
27
28
  const initialPort = typeof argv.port === 'number' ? argv.port : 3000;
@@ -112,7 +113,7 @@ export const getCliVersion = (): string | undefined => {
112
113
  // when running `npm link` the version is 'unknown'
113
114
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
114
115
  if (version === 'unknown') {
115
- version = LOCAL_LINKED_VERSION;
116
+ version = LOCAL_LINKED_CLI_VERSION;
116
117
  }
117
118
  return version;
118
119
  };
package/src/update.tsx CHANGED
@@ -1,49 +1,23 @@
1
- import {
2
- getTargetMintVersion,
3
- downloadTargetMint,
4
- SpinnerLog,
5
- SuccessLog,
6
- ErrorLog,
7
- addLog,
8
- clearLogs,
9
- } from '@mintlify/previewing';
1
+ import { SpinnerLog, SuccessLog, ErrorLog, addLog, clearLogs } from '@mintlify/previewing';
10
2
 
11
3
  import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
12
4
 
13
- export const update = async ({
14
- packageName,
15
- silent,
16
- }: {
17
- packageName: string;
18
- silent?: boolean;
19
- }) => {
20
- if (!silent) {
21
- addLog(<SpinnerLog message="updating..." />);
22
- }
23
- const { cli: existingCliVersion, client: existingClientVersion } = getVersions();
5
+ export const update = async ({ packageName }: { packageName: string }) => {
6
+ addLog(<SpinnerLog message="updating..." />);
7
+ const { cli: existingCliVersion } = getVersions();
24
8
  const latestCliVersion = getLatestCliVersion(packageName);
25
- const latestClientVersion = await getTargetMintVersion();
26
9
  const isUpToDate =
27
- existingCliVersion &&
28
- existingClientVersion &&
29
- latestClientVersion &&
30
- latestCliVersion &&
31
- latestCliVersion.trim() === existingCliVersion.trim() &&
32
- latestClientVersion.trim() === existingClientVersion.trim();
10
+ existingCliVersion && latestCliVersion && latestCliVersion.trim() === existingCliVersion.trim();
33
11
 
34
12
  if (isUpToDate) {
35
- if (!silent) {
36
- addLog(<SuccessLog message="already up to date" />);
37
- }
13
+ addLog(<SuccessLog message="already up to date" />);
38
14
  return;
39
15
  }
40
16
 
41
17
  if (existingCliVersion && latestCliVersion.trim() !== existingCliVersion.trim()) {
42
18
  try {
43
- if (!silent) {
44
- clearLogs();
45
- addLog(<SpinnerLog message={`updating ${packageName} package...`} />);
46
- }
19
+ clearLogs();
20
+ addLog(<SpinnerLog message={`updating ${packageName} package...`} />);
47
21
  const packageManager = await detectPackageManager({ packageName });
48
22
  if (packageManager === 'pnpm') {
49
23
  await execAsync(`pnpm install -g ${packageName}@latest --silent`);
@@ -51,36 +25,13 @@ export const update = async ({
51
25
  await execAsync(`npm install -g ${packageName}@latest --silent`);
52
26
  }
53
27
  } catch (err) {
54
- if (!silent) {
55
- clearLogs();
56
- addLog(<ErrorLog message={`failed to update ${packageName}@latest`} />);
57
- }
28
+ addLog(<ErrorLog message={`failed to update ${packageName}@latest`} />);
58
29
  return;
59
30
  }
60
31
  }
61
32
 
62
- if (latestClientVersion && latestClientVersion !== existingClientVersion) {
63
- try {
64
- if (!silent) {
65
- addLog(<SpinnerLog message={`updating mintlify client to ${latestClientVersion}...`} />);
66
- }
67
- await downloadTargetMint({
68
- targetVersion: latestClientVersion,
69
- existingVersion: existingClientVersion ?? null,
70
- });
71
- } catch (err) {
72
- if (!silent) {
73
- clearLogs();
74
- addLog(<ErrorLog message={`failed to update mintlify client to ${latestClientVersion}`} />);
75
- }
76
- return;
77
- }
78
- }
79
-
80
- if (!silent) {
81
- clearLogs();
82
- addLog(
83
- <SuccessLog message={`updated ${packageName} to the latest version: ${latestCliVersion}`} />
84
- );
85
- }
33
+ clearLogs();
34
+ addLog(
35
+ <SuccessLog message={`updated ${packageName} to the latest version: ${latestCliVersion}`} />
36
+ );
86
37
  };
@@ -1,73 +0,0 @@
1
- import * as previewing from '@mintlify/previewing';
2
-
3
- import { LOCAL_LINKED_VERSION } from '../src/constants.js';
4
- import { getCliVersion } from '../src/helpers.js';
5
- import * as updateModule from '../src/update.js';
6
- import { runCommand } from './utils.js';
7
-
8
- vi.mock('@mintlify/previewing', async () => {
9
- const originalModule =
10
- await vi.importActual<typeof import('@mintlify/previewing')>('@mintlify/previewing');
11
- return {
12
- ...originalModule,
13
- dev: vi.fn().mockResolvedValue(undefined),
14
- addLog: vi.fn().mockResolvedValue(undefined),
15
- };
16
- });
17
-
18
- vi.mock('../src/helpers.js', async () => {
19
- const originalModule =
20
- await vi.importActual<typeof import('../src/helpers.js')>('../src/helpers.js');
21
- return {
22
- ...originalModule,
23
- getCliVersion: vi.fn(),
24
- };
25
- });
26
-
27
- vi.mock('../src/update.js', () => ({
28
- update: vi.fn().mockResolvedValue(undefined),
29
- }));
30
-
31
- const devSpy = vi.spyOn(previewing, 'dev');
32
- const addLogSpy = vi.spyOn(previewing, 'addLog');
33
-
34
- describe('minimum version', () => {
35
- beforeEach(() => {
36
- vi.clearAllMocks();
37
- });
38
-
39
- afterEach(() => {
40
- vi.resetAllMocks();
41
- });
42
-
43
- it('should automatically update the cli if the version is below the minimum', async () => {
44
- vi.mocked(getCliVersion).mockReturnValueOnce('4.1.0');
45
- const updateSpy = vi.spyOn(updateModule, 'update');
46
-
47
- await runCommand('dev');
48
-
49
- expect(updateSpy).toHaveBeenCalled();
50
- expect(devSpy).toHaveBeenCalled();
51
- expect(addLogSpy).not.toHaveBeenCalled();
52
- });
53
- it('should not update the cli if the version is above the minimum', async () => {
54
- vi.mocked(getCliVersion).mockReturnValueOnce('4.2.1');
55
- const updateSpy = vi.spyOn(updateModule, 'update');
56
-
57
- await runCommand('dev');
58
-
59
- expect(updateSpy).not.toHaveBeenCalled();
60
- expect(devSpy).toHaveBeenCalled();
61
- expect(addLogSpy).not.toHaveBeenCalled();
62
- });
63
- it('should not update the cli if the version is linked to local package', async () => {
64
- vi.mocked(getCliVersion).mockReturnValueOnce(LOCAL_LINKED_VERSION);
65
- const updateSpy = vi.spyOn(updateModule, 'update');
66
-
67
- await runCommand('dev');
68
-
69
- expect(updateSpy).not.toHaveBeenCalled();
70
- expect(devSpy).toHaveBeenCalled();
71
- expect(addLogSpy).not.toHaveBeenCalled();
72
- });
73
- });