@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
@@ -1,104 +1,162 @@
1
- import matter from "gray-matter";
2
- import isAbsoluteUrl from "is-absolute-url";
3
- import { remark } from "remark";
4
- import remarkFrontmatter from "remark-frontmatter";
5
- import remarkGfm from "remark-gfm";
6
- import remarkMdx from "remark-mdx";
7
- import { visit } from "unist-util-visit";
8
- const createPage = async (pagePath, pageContent, contentDirectoryPath, openApiFiles) => {
9
- const { data: metadata } = matter(pageContent);
10
- try {
11
- const parsedContent = await preParseMdx(pageContent, contentDirectoryPath);
12
- pageContent = parsedContent;
13
- }
14
- catch (error) {
15
- pageContent = `🚧 A parsing error occured. Please contact the owner of this website.`;
16
- }
17
- // Replace .mdx so we can pass file paths into this function
18
- const slug = pagePath.replace(/\.mdx?$/, "");
19
- let defaultTitle = slugToTitle(slug);
20
- let description;
21
- // Append data from OpenAPI if it exists
22
- if (metadata?.openapi) {
23
- const { title, description: openApiDescription } = getOpenApiTitleAndDescription(openApiFiles, metadata?.openapi);
24
- if (title) {
25
- defaultTitle = title;
26
- }
27
- if (openApiDescription) {
28
- description = openApiDescription;
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
29
7
  }
30
- }
31
- const pageMetadata = {
32
- title: defaultTitle,
33
- description,
34
- ...metadata,
35
- href: optionallyAddLeadingSlash(slug),
36
- };
37
- return {
38
- pageMetadata,
39
- pageContent,
40
- slug: removeLeadingSlash(slug),
8
+ return t;
41
9
  };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
42
20
  };
43
- const preParseMdx = async (fileContent, contentDirectoryPath) => {
44
- const removeContentDirectoryPath = (filePath) => {
45
- const pathArr = createPathArr(filePath);
46
- const contentDirectoryPathArr = createPathArr(contentDirectoryPath);
47
- contentDirectoryPathArr.reverse().forEach((dir, index) => {
48
- if (pathArr[index] === dir) {
49
- pathArr.pop();
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
50
42
  }
51
- });
52
- return "/" + pathArr.join("/");
53
- };
54
- const removeContentDirectoryPaths = () => {
55
- return (tree) => {
56
- visit(tree, (node) => {
57
- if (node == null) {
58
- return;
59
- }
60
- if (node.name === "img" || node.name === "source") {
61
- const srcAttrIndex = node.attributes.findIndex((attr) => attr?.name === "src");
62
- const nodeUrl = node.attributes[srcAttrIndex].value;
63
- if (
64
- // <img/> component
65
- srcAttrIndex !== -1 &&
66
- !isAbsoluteUrl(nodeUrl) &&
67
- !isDataString(nodeUrl)) {
68
- node.attributes[srcAttrIndex].value =
69
- removeContentDirectoryPath(nodeUrl);
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import matter from 'gray-matter';
49
+ import isAbsoluteUrl from 'is-absolute-url';
50
+ import { remark } from 'remark';
51
+ import remarkFrontmatter from 'remark-frontmatter';
52
+ import remarkGfm from 'remark-gfm';
53
+ import remarkMdx from 'remark-mdx';
54
+ import { visit } from 'unist-util-visit';
55
+ var createPage = function (pagePath, pageContent, contentDirectoryPath, openApiFiles) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var metadata, error_1, slug, defaultTitle, description, _a, title, openApiDescription, pageMetadata;
57
+ return __generator(this, function (_b) {
58
+ switch (_b.label) {
59
+ case 0:
60
+ metadata = matter(pageContent).data;
61
+ _b.label = 1;
62
+ case 1:
63
+ _b.trys.push([1, 3, , 4]);
64
+ return [4 /*yield*/, preParseMdx(pageContent, contentDirectoryPath)];
65
+ case 2:
66
+ pageContent = _b.sent();
67
+ return [3 /*break*/, 4];
68
+ case 3:
69
+ error_1 = _b.sent();
70
+ pageContent = "\uD83D\uDEA7 A parsing error occured. Please contact the owner of this website.";
71
+ return [3 /*break*/, 4];
72
+ case 4:
73
+ slug = pagePath.replace(/\.mdx?$/, '');
74
+ defaultTitle = slugToTitle(slug);
75
+ // Append data from OpenAPI if it exists
76
+ if (metadata === null || metadata === void 0 ? void 0 : metadata.openapi) {
77
+ _a = getOpenApiTitleAndDescription(openApiFiles, metadata === null || metadata === void 0 ? void 0 : metadata.openapi), title = _a.title, openApiDescription = _a.description;
78
+ if (title) {
79
+ defaultTitle = title;
80
+ }
81
+ if (openApiDescription) {
82
+ description = openApiDescription;
70
83
  }
71
84
  }
72
- else if (
73
- // ![]() format
74
- node.type === "image" &&
75
- node.url &&
76
- !isAbsoluteUrl(node.url) &&
77
- !isDataString(node.url)) {
78
- node.url = removeContentDirectoryPath(node.url);
79
- }
80
- });
81
- return tree;
82
- };
83
- };
84
- const file = await remark()
85
- .use(remarkMdx)
86
- .use(remarkGfm)
87
- .use(remarkFrontmatter, ["yaml", "toml"])
88
- .use(removeContentDirectoryPaths)
89
- .process(fileContent);
90
- return String(file);
91
- };
92
- const removeLeadingSlash = (str) => {
93
- const path = createPathArr(str);
94
- return path.join("/");
85
+ pageMetadata = __assign(__assign({ title: defaultTitle, description: description }, metadata), { href: optionallyAddLeadingSlash(slug) });
86
+ return [2 /*return*/, {
87
+ pageMetadata: pageMetadata,
88
+ pageContent: pageContent,
89
+ slug: removeLeadingSlash(slug),
90
+ }];
91
+ }
92
+ });
93
+ }); };
94
+ var preParseMdx = function (fileContent, contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () {
95
+ var removeContentDirectoryPath, removeContentDirectoryPaths, file;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0:
99
+ removeContentDirectoryPath = function (filePath) {
100
+ var pathArr = createPathArr(filePath);
101
+ var contentDirectoryPathArr = createPathArr(contentDirectoryPath);
102
+ contentDirectoryPathArr.reverse().forEach(function (dir, index) {
103
+ if (pathArr[index] === dir) {
104
+ pathArr.pop();
105
+ }
106
+ });
107
+ return '/' + pathArr.join('/');
108
+ };
109
+ removeContentDirectoryPaths = function () {
110
+ return function (tree) {
111
+ visit(tree, function (node) {
112
+ if (node == null) {
113
+ return;
114
+ }
115
+ if (node.name === 'img' || node.name === 'source') {
116
+ var srcAttrIndex = node.attributes.findIndex(function (attr) { return (attr === null || attr === void 0 ? void 0 : attr.name) === 'src'; });
117
+ var nodeUrl = node.attributes[srcAttrIndex].value;
118
+ if (
119
+ // <img/> component
120
+ srcAttrIndex !== -1 &&
121
+ !isAbsoluteUrl(nodeUrl) &&
122
+ !isDataString(nodeUrl)) {
123
+ node.attributes[srcAttrIndex].value = removeContentDirectoryPath(nodeUrl);
124
+ }
125
+ }
126
+ else if (
127
+ // ![]() format
128
+ node.type === 'image' &&
129
+ node.url &&
130
+ !isAbsoluteUrl(node.url) &&
131
+ !isDataString(node.url)) {
132
+ node.url = removeContentDirectoryPath(node.url);
133
+ }
134
+ });
135
+ return tree;
136
+ };
137
+ };
138
+ return [4 /*yield*/, remark()
139
+ .use(remarkMdx)
140
+ .use(remarkGfm)
141
+ .use(remarkFrontmatter, ['yaml', 'toml'])
142
+ .use(removeContentDirectoryPaths)
143
+ .process(fileContent)];
144
+ case 1:
145
+ file = _a.sent();
146
+ return [2 /*return*/, String(file)];
147
+ }
148
+ });
149
+ }); };
150
+ var removeLeadingSlash = function (str) {
151
+ var path = createPathArr(str);
152
+ return path.join('/');
95
153
  };
96
- const createPathArr = (path) => {
97
- return path.split("/").filter((dir) => dir !== "");
154
+ var createPathArr = function (path) {
155
+ return path.split('/').filter(function (dir) { return dir !== ''; });
98
156
  };
99
- const isDataString = (str) => str.startsWith("data:");
100
- const getOpenApiTitleAndDescription = (openApiFiles, openApiMetaField) => {
101
- const { operation } = getOpenApiOperationMethodAndEndpoint(openApiFiles, openApiMetaField);
157
+ var isDataString = function (str) { return str.startsWith('data:'); };
158
+ var getOpenApiTitleAndDescription = function (openApiFiles, openApiMetaField) {
159
+ var operation = getOpenApiOperationMethodAndEndpoint(openApiFiles, openApiMetaField).operation;
102
160
  if (operation == null) {
103
161
  return {};
104
162
  }
@@ -107,13 +165,13 @@ const getOpenApiTitleAndDescription = (openApiFiles, openApiMetaField) => {
107
165
  description: operation.description,
108
166
  };
109
167
  };
110
- const getOpenApiOperationMethodAndEndpoint = (openApiFiles, openApiMetaField) => {
111
- const { endpoint, method, filename } = extractMethodAndEndpoint(openApiMetaField);
112
- let path;
113
- openApiFiles?.forEach((file) => {
114
- const openApiFile = file.spec;
115
- const openApiPath = openApiFile.paths && openApiFile.paths[endpoint];
116
- const isFilenameOrNone = !filename || filename === file.filename;
168
+ var getOpenApiOperationMethodAndEndpoint = function (openApiFiles, openApiMetaField) {
169
+ var _a = extractMethodAndEndpoint(openApiMetaField), endpoint = _a.endpoint, method = _a.method, filename = _a.filename;
170
+ var path;
171
+ openApiFiles === null || openApiFiles === void 0 ? void 0 : openApiFiles.forEach(function (file) {
172
+ var openApiFile = file.spec;
173
+ var openApiPath = openApiFile.paths && openApiFile.paths[endpoint];
174
+ var isFilenameOrNone = !filename || filename === file.filename;
117
175
  if (openApiPath && isFilenameOrNone) {
118
176
  path = openApiPath;
119
177
  }
@@ -121,31 +179,27 @@ const getOpenApiOperationMethodAndEndpoint = (openApiFiles, openApiMetaField) =>
121
179
  if (path == null) {
122
180
  return {};
123
181
  }
124
- let operation;
182
+ var operation;
125
183
  if (method) {
126
184
  operation = path[method.toLowerCase()];
127
185
  }
128
186
  else {
129
- const firstOperationKey = Object.keys(path)[0];
187
+ var firstOperationKey = Object.keys(path)[0];
130
188
  operation = path[firstOperationKey];
131
189
  }
132
190
  return {
133
- operation,
134
- method,
135
- endpoint,
191
+ operation: operation,
192
+ method: method,
193
+ endpoint: endpoint,
136
194
  };
137
195
  };
138
- const extractMethodAndEndpoint = (openApiMetaField) => {
139
- const methodRegex = /(get|post|put|delete|patch)\s/i;
140
- const trimmed = openApiMetaField.trim();
141
- const foundMethod = trimmed.match(methodRegex);
142
- const startIndexOfMethod = foundMethod
143
- ? openApiMetaField.indexOf(foundMethod[0])
144
- : 0;
145
- const endIndexOfMethod = foundMethod
146
- ? startIndexOfMethod + foundMethod[0].length - 1
147
- : 0;
148
- const filename = openApiMetaField.substring(0, startIndexOfMethod).trim();
196
+ var extractMethodAndEndpoint = function (openApiMetaField) {
197
+ var methodRegex = /(get|post|put|delete|patch)\s/i;
198
+ var trimmed = openApiMetaField.trim();
199
+ var foundMethod = trimmed.match(methodRegex);
200
+ var startIndexOfMethod = foundMethod ? openApiMetaField.indexOf(foundMethod[0]) : 0;
201
+ var endIndexOfMethod = foundMethod ? startIndexOfMethod + foundMethod[0].length - 1 : 0;
202
+ var filename = openApiMetaField.substring(0, startIndexOfMethod).trim();
149
203
  return {
150
204
  method: foundMethod ? foundMethod[0].slice(0, -1).toUpperCase() : undefined,
151
205
  endpoint: openApiMetaField.substring(endIndexOfMethod).trim(),
@@ -153,17 +207,16 @@ const extractMethodAndEndpoint = (openApiMetaField) => {
153
207
  };
154
208
  };
155
209
  function optionallyAddLeadingSlash(path) {
156
- if (path.startsWith("/")) {
210
+ if (path.startsWith('/')) {
157
211
  return path;
158
212
  }
159
- return "/" + path;
213
+ return '/' + path;
160
214
  }
161
- export const slugToTitle = (slug) => {
162
- const slugArr = slug.split("/");
163
- let defaultTitle = slugArr[slugArr.length - 1].split("-").join(" "); //replace all dashes
164
- defaultTitle = defaultTitle.split("_").join(" "); //replace all underscores
215
+ export var slugToTitle = function (slug) {
216
+ var slugArr = slug.split('/');
217
+ var defaultTitle = slugArr[slugArr.length - 1].split('-').join(' '); //replace all dashes
218
+ defaultTitle = defaultTitle.split('_').join(' '); //replace all underscores
165
219
  defaultTitle = defaultTitle.charAt(0).toUpperCase() + defaultTitle.slice(1); //capitalize first letter
166
220
  return defaultTitle;
167
221
  };
168
222
  export default createPage;
169
- //# sourceMappingURL=createPage.js.map
@@ -1,7 +1,7 @@
1
1
  export declare const extractMethodAndEndpoint: (api: string) => {
2
- method?: string;
2
+ method?: string | undefined;
3
3
  endpoint: string;
4
- filename?: string;
4
+ filename?: string | undefined;
5
5
  };
6
6
  export declare const getOpenApiOperationMethodAndEndpoint: (openApi: any, openApiMetaField: string) => {
7
7
  operation?: undefined;
@@ -9,7 +9,7 @@ export declare const getOpenApiOperationMethodAndEndpoint: (openApi: any, openAp
9
9
  endpoint?: undefined;
10
10
  } | {
11
11
  operation: any;
12
- method: string;
12
+ method: string | undefined;
13
13
  endpoint: string;
14
14
  };
15
15
  export declare const getOpenApiTitleAndDescription: (openApi: any, openApiMetaField: any) => {
@@ -1,25 +1,24 @@
1
- export const extractMethodAndEndpoint = (api) => {
2
- const methodRegex = /(get|post|put|delete|patch)\s/i;
3
- const trimmed = api.trim();
4
- const foundMethod = trimmed.match(methodRegex);
5
- const startIndexOfMethod = foundMethod ? api.indexOf(foundMethod[0]) : 0;
6
- const endIndexOfMethod = foundMethod
7
- ? startIndexOfMethod + foundMethod[0].length - 1
8
- : 0;
9
- const filename = api.substring(0, startIndexOfMethod).trim();
1
+ export var extractMethodAndEndpoint = function (api) {
2
+ var methodRegex = /(get|post|put|delete|patch)\s/i;
3
+ var trimmed = api.trim();
4
+ var foundMethod = trimmed.match(methodRegex);
5
+ var startIndexOfMethod = foundMethod ? api.indexOf(foundMethod[0]) : 0;
6
+ var endIndexOfMethod = foundMethod ? startIndexOfMethod + foundMethod[0].length - 1 : 0;
7
+ var filename = api.substring(0, startIndexOfMethod).trim();
10
8
  return {
11
9
  method: foundMethod ? foundMethod[0].slice(0, -1).toUpperCase() : undefined,
12
10
  endpoint: api.substring(endIndexOfMethod).trim(),
13
11
  filename: filename ? filename : undefined,
14
12
  };
15
13
  };
16
- export const getOpenApiOperationMethodAndEndpoint = (openApi, openApiMetaField) => {
17
- const { endpoint, method, filename } = extractMethodAndEndpoint(openApiMetaField);
18
- let path;
19
- openApi.files?.forEach((file) => {
20
- const openApiFile = file.openapi;
21
- const openApiPath = openApiFile.paths && openApiFile.paths[endpoint];
22
- const isFilenameOrNone = !filename || filename === file.name;
14
+ export var getOpenApiOperationMethodAndEndpoint = function (openApi, openApiMetaField) {
15
+ var _a;
16
+ var _b = extractMethodAndEndpoint(openApiMetaField), endpoint = _b.endpoint, method = _b.method, filename = _b.filename;
17
+ var path;
18
+ (_a = openApi.files) === null || _a === void 0 ? void 0 : _a.forEach(function (file) {
19
+ var openApiFile = file.openapi;
20
+ var openApiPath = openApiFile.paths && openApiFile.paths[endpoint];
21
+ var isFilenameOrNone = !filename || filename === file.name;
23
22
  if (openApiPath && isFilenameOrNone) {
24
23
  path = openApiPath;
25
24
  }
@@ -27,25 +26,25 @@ export const getOpenApiOperationMethodAndEndpoint = (openApi, openApiMetaField)
27
26
  if (path == null) {
28
27
  return {};
29
28
  }
30
- let operation;
29
+ var operation;
31
30
  if (method) {
32
31
  operation = path[method.toLowerCase()];
33
32
  }
34
33
  else {
35
- const firstOperationKey = Object.keys(path)[0];
34
+ var firstOperationKey = Object.keys(path)[0];
36
35
  operation = path[firstOperationKey];
37
36
  }
38
37
  return {
39
- operation,
40
- method,
41
- endpoint,
38
+ operation: operation,
39
+ method: method,
40
+ endpoint: endpoint,
42
41
  };
43
42
  };
44
- export const getOpenApiTitleAndDescription = (openApi, openApiMetaField) => {
43
+ export var getOpenApiTitleAndDescription = function (openApi, openApiMetaField) {
45
44
  if (openApi == null || !openApiMetaField || openApiMetaField == null) {
46
45
  return {};
47
46
  }
48
- const { operation } = getOpenApiOperationMethodAndEndpoint(openApi, openApiMetaField);
47
+ var operation = getOpenApiOperationMethodAndEndpoint(openApi, openApiMetaField).operation;
49
48
  if (operation == null) {
50
49
  return {};
51
50
  }
@@ -54,4 +53,3 @@ export const getOpenApiTitleAndDescription = (openApi, openApiMetaField) => {
54
53
  description: operation.description,
55
54
  };
56
55
  };
57
- //# sourceMappingURL=getOpenApiContext.js.map
@@ -1,22 +1,74 @@
1
- import { promises as _promises } from "fs";
2
- import { pathExists } from "fs-extra";
3
- import pathUtil from "path";
4
- const { readFile } = _promises;
5
- // TODO: Put in prebuild package
6
- export const getConfigPath = async (contentDirectoryPath) => {
7
- if (await pathExists(pathUtil.join(contentDirectoryPath, "mint.json"))) {
8
- return pathUtil.join(contentDirectoryPath, "mint.json");
9
- }
10
- return null;
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
+ });
11
9
  };
12
- // TODO: Put in prebuild package
13
- export const getConfigObj = async (contentDirectoryPath) => {
14
- const configPath = await getConfigPath(contentDirectoryPath);
15
- let configObj = null;
16
- if (configPath) {
17
- const configContents = await readFile(configPath);
18
- configObj = await JSON.parse(configContents.toString());
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 };
19
35
  }
20
- return configObj;
21
36
  };
22
- //# sourceMappingURL=mintConfigFile.js.map
37
+ import { promises as _promises } from 'fs';
38
+ import { pathExists } from 'fs-extra';
39
+ import pathUtil from 'path';
40
+ var readFile = _promises.readFile;
41
+ // TODO: Put in prebuild package
42
+ export var getConfigPath = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () {
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0: return [4 /*yield*/, pathExists(pathUtil.join(contentDirectoryPath, 'mint.json'))];
46
+ case 1:
47
+ if (_a.sent()) {
48
+ return [2 /*return*/, pathUtil.join(contentDirectoryPath, 'mint.json')];
49
+ }
50
+ return [2 /*return*/, null];
51
+ }
52
+ });
53
+ }); };
54
+ // TODO: Put in prebuild package
55
+ export var getConfigObj = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var configPath, configObj, configContents;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0: return [4 /*yield*/, getConfigPath(contentDirectoryPath)];
60
+ case 1:
61
+ configPath = _a.sent();
62
+ configObj = null;
63
+ if (!configPath) return [3 /*break*/, 4];
64
+ return [4 /*yield*/, readFile(configPath)];
65
+ case 2:
66
+ configContents = _a.sent();
67
+ return [4 /*yield*/, JSON.parse(configContents.toString())];
68
+ case 3:
69
+ configObj = _a.sent();
70
+ _a.label = 4;
71
+ case 4: return [2 /*return*/, configObj];
72
+ }
73
+ });
74
+ }); };
@@ -1,7 +1,7 @@
1
1
  export function toTitleCase(text) {
2
- const smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
3
- const alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
4
- const wordSeparators = /([ :–—-])/;
2
+ var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
3
+ var alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
4
+ var wordSeparators = /([ :–—-])/;
5
5
  return text
6
6
  .split(wordSeparators)
7
7
  .map(function (current, index, array) {
@@ -33,4 +33,3 @@ export function toTitleCase(text) {
33
33
  })
34
34
  .join('');
35
35
  }
36
- //# sourceMappingURL=toTitleCase.js.map
@@ -1,2 +1,2 @@
1
- export type PotentialFileCategory = "page" | "snippet" | "mintConfig" | "potentialYamlOpenApiSpec" | "potentialJsonOpenApiSpec" | "staticFile";
2
- export type FileCategory = "page" | "snippet" | "mintConfig" | "openApi" | "staticFile";
1
+ export type PotentialFileCategory = 'page' | 'snippet' | 'mintConfig' | 'potentialYamlOpenApiSpec' | 'potentialJsonOpenApiSpec' | 'staticFile';
2
+ export type FileCategory = 'page' | 'snippet' | 'mintConfig' | 'openApi' | 'staticFile';
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -7,8 +7,7 @@ export declare const openApiCheck: (path: string) => Promise<OpenApiCheckResult>
7
7
  export declare const filterOutNullInGroup: (group: MintNavigation) => {
8
8
  pages: MintNavigationEntry[];
9
9
  group: string;
10
- version?: string;
10
+ version?: string | undefined;
11
11
  };
12
- export declare const getFileList: (dirName: string, og?: string) => Promise<string[]>;
13
12
  export declare const isFileSizeValid: (path: string, maxFileSizeInMb: number) => Promise<boolean>;
14
13
  export declare function isError(obj: unknown): boolean;