@mintlify/previewing 3.1.0 → 3.1.2

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.
Files changed (45) hide show
  1. package/README.md +8 -69
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/constants.js +27 -28
  4. package/dist/downloadImage.js +112 -55
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +2 -3
  7. package/dist/local-preview/helper-commands/installDepsCommand.js +49 -10
  8. package/dist/local-preview/index.d.ts +1 -1
  9. package/dist/local-preview/index.js +221 -131
  10. package/dist/local-preview/listener/categorize.d.ts +1 -1
  11. package/dist/local-preview/listener/categorize.js +134 -79
  12. package/dist/local-preview/listener/generate.d.ts +1 -1
  13. package/dist/local-preview/listener/generate.js +138 -60
  14. package/dist/local-preview/listener/index.js +289 -172
  15. package/dist/local-preview/listener/update.js +75 -20
  16. package/dist/local-preview/listener/utils/createPage.d.ts +1 -1
  17. package/dist/local-preview/listener/utils/createPage.js +176 -123
  18. package/dist/local-preview/listener/utils/getOpenApiContext.d.ts +3 -3
  19. package/dist/local-preview/listener/utils/getOpenApiContext.js +22 -24
  20. package/dist/local-preview/listener/utils/mintConfigFile.js +71 -19
  21. package/dist/local-preview/listener/utils/toTitleCase.js +3 -4
  22. package/dist/local-preview/listener/utils/types.d.ts +2 -2
  23. package/dist/local-preview/listener/utils/types.js +0 -1
  24. package/dist/local-preview/listener/utils.d.ts +1 -2
  25. package/dist/local-preview/listener/utils.js +93 -49
  26. package/dist/tsconfig.tsbuildinfo +1 -0
  27. package/dist/util.d.ts +5 -5
  28. package/dist/util.js +30 -37
  29. package/package.json +6 -1
  30. package/dist/constants.js.map +0 -1
  31. package/dist/downloadImage.js.map +0 -1
  32. package/dist/index.js.map +0 -1
  33. package/dist/local-preview/helper-commands/installDepsCommand.js.map +0 -1
  34. package/dist/local-preview/index.js.map +0 -1
  35. package/dist/local-preview/listener/categorize.js.map +0 -1
  36. package/dist/local-preview/listener/generate.js.map +0 -1
  37. package/dist/local-preview/listener/index.js.map +0 -1
  38. package/dist/local-preview/listener/update.js.map +0 -1
  39. package/dist/local-preview/listener/utils/createPage.js.map +0 -1
  40. package/dist/local-preview/listener/utils/getOpenApiContext.js.map +0 -1
  41. package/dist/local-preview/listener/utils/mintConfigFile.js.map +0 -1
  42. package/dist/local-preview/listener/utils/toTitleCase.js.map +0 -1
  43. package/dist/local-preview/listener/utils/types.js.map +0 -1
  44. package/dist/local-preview/listener/utils.js.map +0 -1
  45. package/dist/util.js.map +0 -1
package/README.md CHANGED
@@ -1,78 +1,17 @@
1
- <div align="center">
2
- <a href="https://mintlify.com">
3
- <img
4
- src="https://res.cloudinary.com/mintlify/image/upload/v1665385627/logo-rounded_zuk7q1.svg"
5
- alt="Mintlify Logo"
6
- height="64"
7
- />
8
- </a>
9
- <br />
10
- <p>
11
- <h3>
12
- <b>
13
- Mintlify CLI
14
- </b>
15
- </h3>
16
- </p>
17
- <p>
18
- The Mintlify CLI is the easiest way to build Mintlify apps from the command line.
19
- </p>
20
- <p>
1
+ # @mintlify/previewing
21
2
 
22
- [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen?logo=github)](/) [![Website](https://img.shields.io/website?url=https%3A%2F%2Fmintlify.com&logo=mintlify)](https://mintlify.com) [![Unit Tests](https://github.com/mintlify/mint/actions/workflows/unit-tests.yaml/badge.svg)](https://github.com/mintlify/mint/actions/workflows/unit-tests.yaml) [![Tweet](https://img.shields.io/twitter/url?url=https%3A%2F%2Fmintlify.com%2F)](https://twitter.com/intent/tweet?url=&text=Check%20out%20%40mintlify) [![Chat on Discord](https://img.shields.io/badge/chat-Discord-7289DA?logo=discord)](https://discord.gg/MPNgtSZkgK) [![Discuss on GitHub](https://img.shields.io/badge/discussions-GitHub-333333?logo=github)](https://github.com/mintlify/mint/discussions)
3
+ Preview Mintlify docs locally.
23
4
 
24
- </p>
25
- <p>
26
- <sub>
27
- Built with ❤︎ by
28
- <a href="https://mintlify.com">
29
- Mintlify
30
- </a>
31
- </sub>
32
- </p>
33
- </div>
34
-
35
- ### 🚀 Installation
36
-
37
- Download the Mintlify CLI using the following command
38
-
39
- ```
40
- npm i -g mintlify
41
- ```
42
-
43
- ### 👩‍💻 Development
44
-
45
- Run the following command at the root of your Mintlify application to preview changes locally.
46
-
47
- ```
48
- mintlify dev
49
- ```
50
-
51
- Note - `mintlify dev` requires `yarn` and it's recommended you install it as a global installation. If you don't have yarn installed already run `npm install --global yarn` in your terminal.
52
-
53
- ### Custom Ports
54
-
55
- Mintlify uses port 3000 by default. You can use the `--port` flag to customize the port Mintlify runs on. For example, use this command to run in port 3333:
5
+ ## 🚀 Installation
56
6
 
57
7
  ```
58
- mintlify dev --port 3333
8
+ npm install @mintlify/previewing
59
9
  ```
60
10
 
61
- You will see an error like this if you try to run Mintlify in a port that's already taken:
62
-
63
- ```
64
- Error: listen EADDRINUSE: address already in use :::3000
65
- ```
66
-
67
- #### Troubleshooting
68
-
69
- Steps you can take if the dev CLI is not working (After each step try to run `mintlify dev` again):
11
+ ## Community
70
12
 
71
- - Make sure you are running in a folder with a `mint.json` file.
72
- - Make sure you are using Node v18 or higher.
73
- - Run `mintlify install` to re-install dependencies.
74
- - Navigate to the `.mintlify` folder in your home directory and delete its contents.
13
+ Join our Discord community if you have questions or just want to chat:
75
14
 
76
- ### 🏃 Get Started
15
+ [![](https://dcbadge.vercel.app/api/server/ACREKdwjG5)](https://discord.gg/ACREKdwjG5)
77
16
 
78
- [Create an account](https://mintlify.com/start) to start using Mintlify for your documentation.
17
+ _Built with 💚 by the Mintlify community._
@@ -1,4 +1,4 @@
1
- export declare const TARGET_MINT_VERSION = "v0.0.9";
1
+ export declare const TARGET_MINT_VERSION = "v0.0.10";
2
2
  export declare const INSTALL_PATH: string;
3
3
  export declare const HOME_DIR: string;
4
4
  export declare const DOT_MINTLIFY: string;
package/dist/constants.js CHANGED
@@ -1,32 +1,31 @@
1
- import path from "path";
2
- import * as url from "url";
3
- import os from "os";
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import * as url from 'url';
4
4
  // Change this to bump to a newer version of mint's client
5
- export const TARGET_MINT_VERSION = "v0.0.9";
5
+ export var TARGET_MINT_VERSION = 'v0.0.10';
6
6
  // package installation location
7
- export const INSTALL_PATH = url.fileURLToPath(new URL(".", import.meta.url));
8
- export const HOME_DIR = os.homedir();
9
- export const DOT_MINTLIFY = path.join(HOME_DIR, ".mintlify");
10
- export const VERSION_PATH = path.join(DOT_MINTLIFY, "mint", "mint-version.txt");
11
- export const CLIENT_PATH = path.join(DOT_MINTLIFY, "mint", "client");
12
- export const MINT_PATH = path.join(DOT_MINTLIFY, "mint");
7
+ export var INSTALL_PATH = url.fileURLToPath(new URL('.', import.meta.url));
8
+ export var HOME_DIR = os.homedir();
9
+ export var DOT_MINTLIFY = path.join(HOME_DIR, '.mintlify');
10
+ export var VERSION_PATH = path.join(DOT_MINTLIFY, 'mint', 'mint-version.txt');
11
+ export var CLIENT_PATH = path.join(DOT_MINTLIFY, 'mint', 'client');
12
+ export var MINT_PATH = path.join(DOT_MINTLIFY, 'mint');
13
13
  // command execution location
14
- export const CMD_EXEC_PATH = process.cwd();
15
- export const SUPPORTED_MEDIA_EXTENSIONS = [
16
- "jpeg",
17
- "jpg",
18
- "jfif",
19
- "pjpeg",
20
- "pjp",
21
- "png",
22
- "svg",
23
- "svgz",
24
- "ico",
25
- "webp",
26
- "gif",
27
- "apng",
28
- "avif",
29
- "bmp",
30
- "mp4",
14
+ export var CMD_EXEC_PATH = process.cwd();
15
+ export var SUPPORTED_MEDIA_EXTENSIONS = [
16
+ 'jpeg',
17
+ 'jpg',
18
+ 'jfif',
19
+ 'pjpeg',
20
+ 'pjp',
21
+ 'png',
22
+ 'svg',
23
+ 'svgz',
24
+ 'ico',
25
+ 'webp',
26
+ 'gif',
27
+ 'apng',
28
+ 'avif',
29
+ 'bmp',
30
+ 'mp4',
31
31
  ];
32
- //# sourceMappingURL=constants.js.map
@@ -1,58 +1,106 @@
1
- import { existsSync, mkdirSync, createWriteStream } from "fs";
2
- import path from "path";
3
- import axios from "axios";
4
- import { getFileExtension } from "./util.js";
5
- import { SUPPORTED_MEDIA_EXTENSIONS } from "./constants.js";
6
- async function writeImageToFile(imageSrc, writePath, overwrite) {
7
- // Avoid unnecessary downloads
8
- if (existsSync(writePath) && !overwrite) {
9
- return Promise.reject({
10
- code: "EEXIST",
11
- });
12
- }
13
- // Create the folders needed if they're missing
14
- mkdirSync(path.dirname(writePath), { recursive: true });
15
- const writer = createWriteStream(writePath);
16
- try {
17
- const response = await axios.get(imageSrc, {
18
- responseType: "stream",
19
- });
20
- // wx prevents overwriting an image with the exact same name
21
- // being created in the time we were downloading
22
- response.data.pipe(writer, {
23
- flag: "wx",
24
- });
25
- return new Promise((resolve, reject) => {
26
- writer.on("finish", resolve);
27
- writer.on("error", reject);
28
- });
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
29
35
  }
30
- catch (e) {
31
- return Promise.reject({
32
- code: "ENOTFOUND",
36
+ };
37
+ import axios from 'axios';
38
+ import { existsSync, mkdirSync, createWriteStream } from 'fs';
39
+ import path from 'path';
40
+ import { SUPPORTED_MEDIA_EXTENSIONS } from './constants.js';
41
+ import { getFileExtension } from './util.js';
42
+ function writeImageToFile(imageSrc, writePath, overwrite) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var writer, response, e_1;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ // Avoid unnecessary downloads
49
+ if (existsSync(writePath) && !overwrite) {
50
+ return [2 /*return*/, Promise.reject({
51
+ code: 'EEXIST',
52
+ })];
53
+ }
54
+ // Create the folders needed if they're missing
55
+ mkdirSync(path.dirname(writePath), { recursive: true });
56
+ writer = createWriteStream(writePath);
57
+ _a.label = 1;
58
+ case 1:
59
+ _a.trys.push([1, 3, , 4]);
60
+ return [4 /*yield*/, axios.get(imageSrc, {
61
+ responseType: 'stream',
62
+ })];
63
+ case 2:
64
+ response = _a.sent();
65
+ // wx prevents overwriting an image with the exact same name
66
+ // being created in the time we were downloading
67
+ response.data.pipe(writer, {
68
+ flag: 'wx',
69
+ });
70
+ return [2 /*return*/, new Promise(function (resolve, reject) {
71
+ writer.on('finish', resolve);
72
+ writer.on('error', reject);
73
+ })];
74
+ case 3:
75
+ e_1 = _a.sent();
76
+ return [2 /*return*/, Promise.reject({
77
+ code: 'ENOTFOUND',
78
+ })];
79
+ case 4: return [2 /*return*/];
80
+ }
33
81
  });
34
- }
82
+ });
35
83
  }
36
84
  export function isValidImageSrc(src) {
37
85
  if (!src) {
38
86
  return false;
39
87
  }
40
88
  // We do not support downloading base64 in-line images.
41
- if (src.startsWith("data:")) {
89
+ if (src.startsWith('data:')) {
42
90
  return false;
43
91
  }
44
- const imageHref = removeMetadataFromImageSrc(src);
45
- const ext = getFileExtension(imageHref);
92
+ var imageHref = removeMetadataFromImageSrc(src);
93
+ var ext = getFileExtension(imageHref);
46
94
  if (ext && !SUPPORTED_MEDIA_EXTENSIONS.includes(ext)) {
47
- console.error("🚨 We do not support the file extension: " + ext);
95
+ console.error('🚨 We do not support the file extension: ' + ext);
48
96
  return false;
49
97
  }
50
98
  return true;
51
99
  }
52
100
  export function removeMetadataFromImageSrc(src) {
53
101
  // Part of the URL standard
54
- const metadataSymbols = ["?", "#"];
55
- metadataSymbols.forEach((dividerSymbol) => {
102
+ var metadataSymbols = ['?', '#'];
103
+ metadataSymbols.forEach(function (dividerSymbol) {
56
104
  // Some frameworks add metadata after the file extension, we need to remove that.
57
105
  src = src.split(dividerSymbol)[0];
58
106
  });
@@ -60,23 +108,32 @@ export function removeMetadataFromImageSrc(src) {
60
108
  }
61
109
  export function cleanImageSrc(src, origin) {
62
110
  // Add origin if the image tags are using relative sources
63
- return src.startsWith("http") ? src : new URL(src, origin).href;
111
+ return src.startsWith('http') ? src : new URL(src, origin).href;
64
112
  }
65
- export default async function downloadImage(imageSrc, writePath, overwrite = false) {
66
- await writeImageToFile(imageSrc, writePath, overwrite)
67
- .then(() => {
68
- console.log("🖼️ - " + writePath);
69
- })
70
- .catch((e) => {
71
- if (e.code === "EEXIST") {
72
- console.log(`❌ Skipping existing image ${writePath}`);
73
- }
74
- else if (e.code === "ENOTFOUND") {
75
- console.error(`🚨 Cannot download the image, address not found ${imageSrc}`);
76
- }
77
- else {
78
- console.error(e);
79
- }
113
+ export default function downloadImage(imageSrc, writePath, overwrite) {
114
+ if (overwrite === void 0) { overwrite = false; }
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0: return [4 /*yield*/, writeImageToFile(imageSrc, writePath, overwrite)
119
+ .then(function () {
120
+ console.log('🖼️ - ' + writePath);
121
+ })
122
+ .catch(function (e) {
123
+ if (e.code === 'EEXIST') {
124
+ console.log("\u274C Skipping existing image ".concat(writePath));
125
+ }
126
+ else if (e.code === 'ENOTFOUND') {
127
+ console.error("\uD83D\uDEA8 Cannot download the image, address not found ".concat(imageSrc));
128
+ }
129
+ else {
130
+ console.error(e);
131
+ }
132
+ })];
133
+ case 1:
134
+ _a.sent();
135
+ return [2 /*return*/];
136
+ }
137
+ });
80
138
  });
81
139
  }
82
- //# sourceMappingURL=downloadImage.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import dev from "./local-preview/index.js";
2
- import installDepsCommand from "./local-preview/helper-commands/installDepsCommand.js";
1
+ import installDepsCommand from './local-preview/helper-commands/installDepsCommand.js';
2
+ import dev from './local-preview/index.js';
3
3
  export { dev, installDepsCommand };
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import dev from "./local-preview/index.js";
2
- import installDepsCommand from "./local-preview/helper-commands/installDepsCommand.js";
1
+ import installDepsCommand from './local-preview/helper-commands/installDepsCommand.js';
2
+ import dev from './local-preview/index.js';
3
3
  export { dev, installDepsCommand };
4
- //# sourceMappingURL=index.js.map
@@ -1,12 +1,51 @@
1
- import shell from "shelljs";
2
- import { CLIENT_PATH } from "../../constants.js";
3
- import { buildLogger, ensureYarn } from "../../util.js";
4
- const installDeps = async () => {
5
- const logger = buildLogger("");
6
- ensureYarn(logger);
7
- shell.cd(CLIENT_PATH);
8
- shell.exec("yarn");
9
- logger.succeed("Dependencies installed.");
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
10
9
  };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import shell from 'shelljs';
38
+ import { CLIENT_PATH } from '../../constants.js';
39
+ import { buildLogger, ensureYarn } from '../../util.js';
40
+ var installDeps = function () { return __awaiter(void 0, void 0, void 0, function () {
41
+ var logger;
42
+ return __generator(this, function (_a) {
43
+ logger = buildLogger('');
44
+ ensureYarn(logger);
45
+ shell.cd(CLIENT_PATH);
46
+ shell.exec('yarn');
47
+ logger.succeed('Dependencies installed.');
48
+ return [2 /*return*/];
49
+ });
50
+ }); };
11
51
  export default installDeps;
12
- //# sourceMappingURL=installDepsCommand.js.map
@@ -1,3 +1,3 @@
1
- import { ArgumentsCamelCase } from "yargs";
1
+ import { ArgumentsCamelCase } from 'yargs';
2
2
  declare const dev: (argv: ArgumentsCamelCase) => Promise<void>;
3
3
  export default dev;