@mintlify/cli 4.0.628 → 4.0.630

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
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { getTargetMintVersion, downloadTargetMint, SpinnerLog, SuccessLog, ErrorLog, addLog, clearLogs, } from '@mintlify/previewing';
12
- import { execAsync, getLatestCliVersion, getVersions } from './helpers.js';
12
+ import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
13
13
  export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packageName, silent, }) {
14
14
  if (!silent) {
15
15
  addLog(_jsx(SpinnerLog, { message: "updating..." }));
@@ -35,10 +35,17 @@ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packa
35
35
  clearLogs();
36
36
  addLog(_jsx(SpinnerLog, { message: `updating ${packageName} package...` }));
37
37
  }
38
- yield execAsync(`npm install -g ${packageName}@latest --silent`);
38
+ const packageManager = yield detectPackageManager({ packageName });
39
+ if (packageManager === 'pnpm') {
40
+ yield execAsync(`pnpm install -g ${packageName}@latest --silent`);
41
+ }
42
+ else {
43
+ yield execAsync(`npm install -g ${packageName}@latest --silent`);
44
+ }
39
45
  }
40
46
  catch (err) {
41
47
  if (!silent) {
48
+ clearLogs();
42
49
  addLog(_jsx(ErrorLog, { message: `failed to update ${packageName}@latest` }));
43
50
  }
44
51
  return;
@@ -56,6 +63,7 @@ export const update = (_a) => __awaiter(void 0, [_a], void 0, function* ({ packa
56
63
  }
57
64
  catch (err) {
58
65
  if (!silent) {
66
+ clearLogs();
59
67
  addLog(_jsx(ErrorLog, { message: `failed to update mintlify client to ${latestClientVersion}` }));
60
68
  }
61
69
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.628",
3
+ "version": "4.0.630",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -39,12 +39,12 @@
39
39
  "format:check": "prettier . --check"
40
40
  },
41
41
  "dependencies": {
42
- "@mintlify/common": "1.0.453",
43
- "@mintlify/link-rot": "3.0.577",
44
- "@mintlify/models": "0.0.207",
45
- "@mintlify/prebuild": "1.0.571",
46
- "@mintlify/previewing": "4.0.615",
47
- "@mintlify/validation": "0.1.416",
42
+ "@mintlify/common": "1.0.454",
43
+ "@mintlify/link-rot": "3.0.578",
44
+ "@mintlify/models": "0.0.208",
45
+ "@mintlify/prebuild": "1.0.572",
46
+ "@mintlify/previewing": "4.0.616",
47
+ "@mintlify/validation": "0.1.417",
48
48
  "chalk": "^5.2.0",
49
49
  "detect-port": "^1.5.1",
50
50
  "fs-extra": "^11.2.0",
@@ -73,5 +73,5 @@
73
73
  "vitest": "^2.0.4",
74
74
  "vitest-mock-process": "^1.0.4"
75
75
  },
76
- "gitHead": "289495d2fd9b588b475da6c8ca46f7b709cc0be2"
76
+ "gitHead": "085e2f2510b4f9a01aecbe54fd78e20f3b8945fb"
77
77
  }
package/src/helpers.tsx CHANGED
@@ -174,3 +174,16 @@ export const terminate = async (code: number) => {
174
174
  };
175
175
 
176
176
  export const execAsync = promisify(exec);
177
+
178
+ export const detectPackageManager = async ({ packageName }: { packageName: string }) => {
179
+ try {
180
+ const { stdout: packagePath } = await execAsync(`which ${packageName}`);
181
+ if (packagePath.includes('pnpm')) {
182
+ return 'pnpm';
183
+ } else {
184
+ return 'npm';
185
+ }
186
+ } catch (error) {
187
+ return 'npm';
188
+ }
189
+ };
package/src/index.ts CHANGED
@@ -6,7 +6,10 @@ import { fileURLToPath } from 'url';
6
6
  const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
8
8
 
9
- const packageName = process.argv[1]?.split('/').pop() ?? 'mint';
9
+ const packageName =
10
+ process.argv[1]?.split('/').pop() === 'index.js'
11
+ ? 'mint'
12
+ : process.argv[1]?.split('/').pop() ?? 'mint';
10
13
 
11
14
  let cli: ChildProcess | null = null;
12
15
  let isShuttingDown = false;
package/src/update.tsx CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  clearLogs,
9
9
  } from '@mintlify/previewing';
10
10
 
11
- import { execAsync, getLatestCliVersion, getVersions } from './helpers.js';
11
+ import { execAsync, getLatestCliVersion, getVersions, detectPackageManager } from './helpers.js';
12
12
 
13
13
  export const update = async ({
14
14
  packageName,
@@ -44,9 +44,15 @@ export const update = async ({
44
44
  clearLogs();
45
45
  addLog(<SpinnerLog message={`updating ${packageName} package...`} />);
46
46
  }
47
- await execAsync(`npm install -g ${packageName}@latest --silent`);
47
+ const packageManager = await detectPackageManager({ packageName });
48
+ if (packageManager === 'pnpm') {
49
+ await execAsync(`pnpm install -g ${packageName}@latest --silent`);
50
+ } else {
51
+ await execAsync(`npm install -g ${packageName}@latest --silent`);
52
+ }
48
53
  } catch (err) {
49
54
  if (!silent) {
55
+ clearLogs();
50
56
  addLog(<ErrorLog message={`failed to update ${packageName}@latest`} />);
51
57
  }
52
58
  return;
@@ -64,6 +70,7 @@ export const update = async ({
64
70
  });
65
71
  } catch (err) {
66
72
  if (!silent) {
73
+ clearLogs();
67
74
  addLog(<ErrorLog message={`failed to update mintlify client to ${latestClientVersion}`} />);
68
75
  }
69
76
  return;