mintlify 2.0.4 → 2.0.6
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/constants.js +17 -0
- package/bin/constants.js.map +1 -1
- package/bin/downloadImage.js +47 -2
- package/bin/downloadImage.js.map +1 -1
- package/bin/index.js +5 -3
- package/bin/index.js.map +1 -1
- package/bin/local-preview/index.js +2 -1
- package/bin/local-preview/index.js.map +1 -1
- package/bin/local-preview/listener/{categorizeFiles.js → categorize.js} +53 -3
- package/bin/local-preview/listener/categorize.js.map +1 -0
- package/bin/local-preview/listener/generate.js +1 -1
- package/bin/local-preview/listener/generate.js.map +1 -1
- package/bin/local-preview/listener/index.js +145 -108
- package/bin/local-preview/listener/index.js.map +1 -1
- package/bin/local-preview/listener/update.js +1 -1
- package/bin/local-preview/listener/update.js.map +1 -1
- package/bin/scraping/combineNavWithEmptyGroupTitles.js.map +1 -1
- package/bin/scraping/downloadAllImages.js +9 -38
- package/bin/scraping/downloadAllImages.js.map +1 -1
- package/bin/scraping/downloadLogoImage.js +13 -0
- package/bin/scraping/downloadLogoImage.js.map +1 -0
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +1 -1
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +1 -1
- package/bin/scraping/scrapeGettingFileNameFromUrl.js +1 -2
- package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +1 -1
- package/bin/scraping/scrapePage.js +3 -2
- package/bin/scraping/scrapePage.js.map +1 -1
- package/bin/scraping/scrapePageCommands.js +1 -1
- package/bin/scraping/scrapePageCommands.js.map +1 -1
- package/bin/scraping/scrapeSection.js +4 -1
- package/bin/scraping/scrapeSection.js.map +1 -1
- package/bin/scraping/scrapeSectionCommands.js +2 -2
- package/bin/scraping/scrapeSectionCommands.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js +2 -2
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +5 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js +2 -2
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +7 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeReadMePage.js +2 -2
- package/bin/scraping/site-scrapers/scrapeReadMePage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js +9 -3
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +1 -1
- package/bin/util.js +4 -2
- package/bin/util.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +18 -0
- package/src/downloadImage.ts +61 -3
- package/src/index.ts +10 -3
- package/src/local-preview/index.ts +2 -1
- package/src/local-preview/listener/{categorizeFiles.ts → categorize.ts} +56 -2
- package/src/local-preview/listener/generate.ts +1 -1
- package/src/local-preview/listener/index.ts +163 -143
- package/src/local-preview/listener/update.ts +1 -1
- package/src/local-preview/listener/utils/types.ts +15 -0
- package/src/scraping/combineNavWithEmptyGroupTitles.ts +4 -4
- package/src/scraping/downloadAllImages.ts +12 -39
- package/src/scraping/downloadLogoImage.ts +24 -0
- package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +3 -1
- package/src/scraping/scrapeGettingFileNameFromUrl.ts +4 -4
- package/src/scraping/scrapePage.ts +6 -9
- package/src/scraping/scrapePageCommands.ts +2 -2
- package/src/scraping/scrapeSection.ts +7 -2
- package/src/scraping/scrapeSectionCommands.ts +7 -4
- package/src/scraping/site-scrapers/scrapeDocusaurusPage.ts +3 -1
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +9 -4
- package/src/scraping/site-scrapers/scrapeGitBookPage.ts +2 -0
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +12 -4
- package/src/scraping/site-scrapers/scrapeReadMePage.ts +3 -1
- package/src/scraping/site-scrapers/scrapeReadMeSection.ts +14 -6
- package/src/types.d.ts +29 -0
- package/src/util.ts +6 -5
- package/bin/local-preview/listener/categorizeFiles.js.map +0 -1
- package/bin/local-preview/listener/utils/fileIsMdxOrMd.js +0 -12
- package/bin/local-preview/listener/utils/fileIsMdxOrMd.js.map +0 -1
- package/bin/local-preview/utils/categorizeFiles.js +0 -63
- package/bin/local-preview/utils/categorizeFiles.js.map +0 -1
- package/bin/local-preview/utils/getOpenApiContext.js +0 -58
- package/bin/local-preview/utils/getOpenApiContext.js.map +0 -1
- package/bin/local-preview/utils/injectFavicons.js +0 -72
- package/bin/local-preview/utils/injectFavicons.js.map +0 -1
- package/bin/local-preview/utils/listener.js +0 -116
- package/bin/local-preview/utils/listener.js.map +0 -1
- package/bin/local-preview/utils/metadata.js +0 -118
- package/bin/local-preview/utils/metadata.js.map +0 -1
- package/bin/local-preview/utils/mintConfigFile.js +0 -43
- package/bin/local-preview/utils/mintConfigFile.js.map +0 -1
- package/bin/local-preview/utils/openApiCheck.js +0 -15
- package/bin/local-preview/utils/openApiCheck.js.map +0 -1
- package/bin/local-preview/utils/slugToTitle.js +0 -8
- package/bin/local-preview/utils/slugToTitle.js.map +0 -1
- package/bin/navigation.js +0 -4
- package/bin/navigation.js.map +0 -1
- package/bin/pageTemplate.js +0 -30
- package/bin/pageTemplate.js.map +0 -1
- package/src/local-preview/listener/utils/fileIsMdxOrMd.ts +0 -11
- package/src/navigation.ts +0 -12
- package/src/pageTemplate.ts +0 -32
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
import { objToReadableString } from "../util.js";
|
|
2
3
|
|
|
3
4
|
export async function scrapeSection(
|
|
4
|
-
scrapeFunc:
|
|
5
|
+
scrapeFunc: ScrapeSectionFn,
|
|
5
6
|
html: string,
|
|
6
7
|
origin: string,
|
|
7
8
|
overwrite: boolean,
|
|
@@ -10,10 +11,14 @@ export async function scrapeSection(
|
|
|
10
11
|
console.log(
|
|
11
12
|
`Started scraping${overwrite ? ", overwrite mode is on" : ""}...`
|
|
12
13
|
);
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
const imageBaseDir = path.join(cwd, "images");
|
|
16
|
+
|
|
13
17
|
const groupsConfig = await scrapeFunc(
|
|
14
18
|
html,
|
|
15
19
|
origin,
|
|
16
|
-
|
|
20
|
+
cwd,
|
|
21
|
+
imageBaseDir,
|
|
17
22
|
overwrite,
|
|
18
23
|
version
|
|
19
24
|
);
|
|
@@ -9,7 +9,10 @@ import openNestedGitbookMenus from "./site-scrapers/openNestedGitbookMenus.js";
|
|
|
9
9
|
import { scrapeReadMeSection } from "./site-scrapers/scrapeReadMeSection.js";
|
|
10
10
|
import { startBrowser } from "../browser.js";
|
|
11
11
|
|
|
12
|
-
export async function scrapeSectionAxiosWrapper(
|
|
12
|
+
export async function scrapeSectionAxiosWrapper(
|
|
13
|
+
argv: any,
|
|
14
|
+
scrapeFunc: ScrapeSectionFn
|
|
15
|
+
) {
|
|
13
16
|
const href = getHrefFromArgs(argv);
|
|
14
17
|
const res = await axios.get(href);
|
|
15
18
|
const html = res.data;
|
|
@@ -17,7 +20,7 @@ export async function scrapeSectionAxiosWrapper(argv: any, scrapeFunc: any) {
|
|
|
17
20
|
scrapeFunc,
|
|
18
21
|
html,
|
|
19
22
|
getOrigin(href),
|
|
20
|
-
argv.overwrite,
|
|
23
|
+
!!argv.overwrite,
|
|
21
24
|
undefined
|
|
22
25
|
);
|
|
23
26
|
process.exit(0);
|
|
@@ -46,7 +49,7 @@ export async function scrapeGitbookSectionCommand(argv: any) {
|
|
|
46
49
|
async function scrapeSectionOpeningAllNested(
|
|
47
50
|
argv: any,
|
|
48
51
|
openLinks: any,
|
|
49
|
-
scrapeFunc:
|
|
52
|
+
scrapeFunc: ScrapeSectionFn,
|
|
50
53
|
version?: string
|
|
51
54
|
) {
|
|
52
55
|
const href = getHrefFromArgs(argv);
|
|
@@ -63,7 +66,7 @@ async function scrapeSectionOpeningAllNested(
|
|
|
63
66
|
scrapeFunc,
|
|
64
67
|
html,
|
|
65
68
|
getOrigin(href),
|
|
66
|
-
argv.overwrite,
|
|
69
|
+
!!argv.overwrite,
|
|
67
70
|
version
|
|
68
71
|
);
|
|
69
72
|
process.exit(0);
|
|
@@ -8,6 +8,7 @@ export async function scrapeDocusaurusPage(
|
|
|
8
8
|
origin: string,
|
|
9
9
|
cliDir: string,
|
|
10
10
|
imageBaseDir: string,
|
|
11
|
+
overwrite: boolean,
|
|
11
12
|
version: string | undefined // expects "2", or "3". Have not written support for "1" yet
|
|
12
13
|
) {
|
|
13
14
|
const $ = cheerio.load(html);
|
|
@@ -33,7 +34,8 @@ export async function scrapeDocusaurusPage(
|
|
|
33
34
|
$,
|
|
34
35
|
markdownContent,
|
|
35
36
|
origin,
|
|
36
|
-
imageBaseDir
|
|
37
|
+
imageBaseDir,
|
|
38
|
+
overwrite
|
|
37
39
|
);
|
|
38
40
|
|
|
39
41
|
const markdownHtml = markdownContent.html();
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import cheerio from "cheerio";
|
|
2
|
-
import { NavigationEntry } from "../..//navigation.js";
|
|
3
2
|
import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js";
|
|
4
3
|
import combineNavWithEmptyGroupTitles from "../combineNavWithEmptyGroupTitles.js";
|
|
5
4
|
import { scrapeDocusaurusPage } from "./scrapeDocusaurusPage.js";
|
|
6
5
|
import { getDocusaurusLinksPerGroup } from "./links-per-group/getDocusaurusLinksPerGroup.js";
|
|
6
|
+
import downloadLogoImage from "../downloadLogoImage.js";
|
|
7
7
|
|
|
8
8
|
export async function scrapeDocusaurusSection(
|
|
9
9
|
html: string,
|
|
10
10
|
origin: string,
|
|
11
11
|
cliDir: string,
|
|
12
|
+
imageBaseDir: string,
|
|
12
13
|
overwrite: boolean,
|
|
13
14
|
version: string
|
|
14
|
-
) {
|
|
15
|
+
): Promise<MintNavigation[]> {
|
|
15
16
|
const $ = cheerio.load(html);
|
|
16
17
|
|
|
18
|
+
// Download the logo
|
|
19
|
+
const logoSrc = $(".navbar__logo img").attr("src");
|
|
20
|
+
downloadLogoImage(logoSrc, imageBaseDir, origin, overwrite);
|
|
21
|
+
|
|
17
22
|
// Get all the navigation sections
|
|
18
23
|
const navigationSections = $(".theme-doc-sidebar-menu").first().children();
|
|
19
24
|
|
|
20
25
|
// Get all links per group
|
|
21
|
-
const groupsConfig = getDocusaurusLinksPerGroup(
|
|
26
|
+
const groupsConfig: MintNavigation[] = getDocusaurusLinksPerGroup(
|
|
22
27
|
navigationSections,
|
|
23
28
|
$,
|
|
24
29
|
version
|
|
@@ -32,7 +37,7 @@ export async function scrapeDocusaurusSection(
|
|
|
32
37
|
reducedGroupsConfig.map(async (groupConfig) => {
|
|
33
38
|
groupConfig.pages = (
|
|
34
39
|
await Promise.all(
|
|
35
|
-
groupConfig.pages.map(async (navEntry:
|
|
40
|
+
groupConfig.pages.map(async (navEntry: MintNavigationEntry) =>
|
|
36
41
|
// Docusaurus requires a directory on all sections wheras we use root.
|
|
37
42
|
// /docs is their default directory so we remove it
|
|
38
43
|
scrapeGettingFileNameFromUrl(
|
|
@@ -8,6 +8,7 @@ export async function scrapeGitBookPage(
|
|
|
8
8
|
origin: string,
|
|
9
9
|
cliDir: string,
|
|
10
10
|
imageBaseDir: string,
|
|
11
|
+
overwrite: boolean,
|
|
11
12
|
_: string | undefined // version
|
|
12
13
|
) {
|
|
13
14
|
const $ = cheerio.load(html);
|
|
@@ -33,6 +34,7 @@ export async function scrapeGitBookPage(
|
|
|
33
34
|
content,
|
|
34
35
|
origin,
|
|
35
36
|
imageBaseDir,
|
|
37
|
+
overwrite,
|
|
36
38
|
modifyFileName
|
|
37
39
|
);
|
|
38
40
|
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import cheerio from "cheerio";
|
|
2
|
-
import
|
|
2
|
+
import path from "path";
|
|
3
3
|
import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js";
|
|
4
4
|
import { scrapeGitBookPage } from "./scrapeGitBookPage.js";
|
|
5
5
|
import combineNavWithEmptyGroupTitles from "../combineNavWithEmptyGroupTitles.js";
|
|
6
6
|
import getLinksRecursivelyGitBook from "./links-per-group/getLinksRecursivelyGitBook.js";
|
|
7
7
|
import alternateGroupTitle from "./alternateGroupTitle.js";
|
|
8
|
+
import downloadLogoImage from "../downloadLogoImage.js";
|
|
8
9
|
|
|
9
10
|
export async function scrapeGitBookSection(
|
|
10
11
|
html: string,
|
|
11
12
|
origin: string,
|
|
12
13
|
cliDir: string,
|
|
14
|
+
imageBaseDir: string,
|
|
13
15
|
overwrite: boolean,
|
|
14
16
|
version: string | undefined
|
|
15
|
-
) {
|
|
17
|
+
): Promise<MintNavigationEntry[]> {
|
|
16
18
|
const $ = cheerio.load(html);
|
|
17
19
|
|
|
20
|
+
// Download the logo
|
|
21
|
+
const logoSrc = $('a[data-testid="public.headerHomeLink"] img')
|
|
22
|
+
.first()
|
|
23
|
+
.attr("src");
|
|
24
|
+
downloadLogoImage(logoSrc, imageBaseDir, origin, overwrite);
|
|
25
|
+
|
|
18
26
|
// Get all the navigation sections
|
|
19
27
|
// Some variants of the GitBook UI show the logo and search base in the side navigation bar,
|
|
20
28
|
// but the navigation sections are always the last value.
|
|
@@ -28,7 +36,7 @@ export async function scrapeGitBookSection(
|
|
|
28
36
|
.children();
|
|
29
37
|
|
|
30
38
|
// Get all links per group
|
|
31
|
-
const groupsConfig = navigationSections
|
|
39
|
+
const groupsConfig: MintNavigation[] = navigationSections
|
|
32
40
|
.map((i, s) => {
|
|
33
41
|
const section = $(s);
|
|
34
42
|
const sectionTitle = $(section)
|
|
@@ -56,7 +64,7 @@ export async function scrapeGitBookSection(
|
|
|
56
64
|
|
|
57
65
|
// Scrape each link in the navigation.
|
|
58
66
|
const groupsConfigCleanPaths = await Promise.all(
|
|
59
|
-
reducedGroupsConfig.map(async (navEntry:
|
|
67
|
+
reducedGroupsConfig.map(async (navEntry: MintNavigationEntry) => {
|
|
60
68
|
return await scrapeGettingFileNameFromUrl(
|
|
61
69
|
navEntry,
|
|
62
70
|
cliDir,
|
|
@@ -8,6 +8,7 @@ export async function scrapeReadMePage(
|
|
|
8
8
|
origin: string,
|
|
9
9
|
cliDir: string,
|
|
10
10
|
imageBaseDir: string,
|
|
11
|
+
overwrite: boolean,
|
|
11
12
|
_: string | undefined // version
|
|
12
13
|
) {
|
|
13
14
|
const $ = cheerio.load(html);
|
|
@@ -31,7 +32,8 @@ export async function scrapeReadMePage(
|
|
|
31
32
|
$,
|
|
32
33
|
content,
|
|
33
34
|
origin,
|
|
34
|
-
imageBaseDir
|
|
35
|
+
imageBaseDir,
|
|
36
|
+
overwrite
|
|
35
37
|
);
|
|
36
38
|
|
|
37
39
|
const nhm = new NodeHtmlMarkdown({ useInlineLinks: false });
|
|
@@ -2,17 +2,22 @@ import cheerio from "cheerio";
|
|
|
2
2
|
import { scrapeReadMePage } from "./scrapeReadMePage.js";
|
|
3
3
|
import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js";
|
|
4
4
|
import getLinksRecursively from "./links-per-group/getLinksRecursively.js";
|
|
5
|
-
import
|
|
5
|
+
import downloadLogoImage from "../downloadLogoImage.js";
|
|
6
6
|
|
|
7
7
|
export async function scrapeReadMeSection(
|
|
8
8
|
html: string,
|
|
9
9
|
origin: string,
|
|
10
10
|
cliDir: string,
|
|
11
|
+
imageBaseDir: string,
|
|
11
12
|
overwrite: boolean,
|
|
12
13
|
version: string | undefined
|
|
13
|
-
) {
|
|
14
|
+
): Promise<MintNavigationEntry[]> {
|
|
14
15
|
const $ = cheerio.load(html);
|
|
15
16
|
|
|
17
|
+
// Download the logo
|
|
18
|
+
const logoSrc = $(".rm-Logo-img").first().attr("src");
|
|
19
|
+
downloadLogoImage(logoSrc, imageBaseDir, origin, overwrite);
|
|
20
|
+
|
|
16
21
|
// Get all the navigation sections, but only from the first
|
|
17
22
|
// sidebar found. There are multiple in the HTML for mobile
|
|
18
23
|
// responsiveness but they all have the same links.
|
|
@@ -20,7 +25,7 @@ export async function scrapeReadMeSection(
|
|
|
20
25
|
.first()
|
|
21
26
|
.find(".rm-Sidebar-section");
|
|
22
27
|
|
|
23
|
-
const groupsConfig = navigationSections
|
|
28
|
+
const groupsConfig: MintNavigation[] = navigationSections
|
|
24
29
|
.map((i, s) => {
|
|
25
30
|
const section = $(s);
|
|
26
31
|
const sectionTitle = section.find("h3").first().text();
|
|
@@ -43,10 +48,11 @@ export async function scrapeReadMeSection(
|
|
|
43
48
|
})
|
|
44
49
|
.toArray();
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
// Scrape each link in the navigation.
|
|
52
|
+
const groupsConfigCleanPaths = await Promise.all(
|
|
53
|
+
groupsConfig.map(async (navEntry: MintNavigationEntry) => {
|
|
48
54
|
return await scrapeGettingFileNameFromUrl(
|
|
49
|
-
// ReadMe requires a directory on all sections
|
|
55
|
+
// ReadMe requires a directory on all sections whereas we use root.
|
|
50
56
|
// /docs is their default directory so we remove it
|
|
51
57
|
navEntry,
|
|
52
58
|
cliDir,
|
|
@@ -59,4 +65,6 @@ export async function scrapeReadMeSection(
|
|
|
59
65
|
);
|
|
60
66
|
})
|
|
61
67
|
);
|
|
68
|
+
|
|
69
|
+
return groupsConfigCleanPaths;
|
|
62
70
|
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type MintPage = {
|
|
2
|
+
title?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
markdown?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type MintNavigation = {
|
|
8
|
+
group: string;
|
|
9
|
+
pages: MintNavigationEntry[];
|
|
10
|
+
};
|
|
11
|
+
type MintNavigationEntry = string | MintNavigation;
|
|
12
|
+
|
|
13
|
+
type ScrapePageFn = (
|
|
14
|
+
html: string,
|
|
15
|
+
origin: string,
|
|
16
|
+
cliDir: string,
|
|
17
|
+
imageBaseDir: string,
|
|
18
|
+
overwrite: boolean,
|
|
19
|
+
version: string | undefined
|
|
20
|
+
) => Promise<MintPage>;
|
|
21
|
+
|
|
22
|
+
type ScrapeSectionFn = (
|
|
23
|
+
html: string,
|
|
24
|
+
origin: string,
|
|
25
|
+
cliDir: string,
|
|
26
|
+
imageBaseDir: string,
|
|
27
|
+
overwrite: boolean,
|
|
28
|
+
version: string | undefined
|
|
29
|
+
) => Promise<MintNavigationEntry[]>;
|
package/src/util.ts
CHANGED
|
@@ -57,14 +57,13 @@ export const Page = (
|
|
|
57
57
|
return `---\ntitle: ${title}${optionalDescription}\n---\n\n${markdown}`;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
|
|
61
60
|
export function getOrigin(url: string) {
|
|
62
61
|
// eg. https://google.com -> https://google.com
|
|
63
62
|
// https://google.com/page -> https://google.com
|
|
64
63
|
return new URL(url).origin;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
export function objToReadableString(objs:
|
|
66
|
+
export function objToReadableString(objs: MintNavigationEntry[]) {
|
|
68
67
|
// Two spaces as indentation
|
|
69
68
|
return objs.map((obj) => JSON.stringify(obj, null, 2)).join(",\n");
|
|
70
69
|
}
|
|
@@ -133,10 +132,12 @@ export const buildLogger = (startText: string = "") => {
|
|
|
133
132
|
};
|
|
134
133
|
|
|
135
134
|
export const getFileExtension = (filename: string) => {
|
|
136
|
-
|
|
137
|
-
filename.
|
|
138
|
-
filename
|
|
135
|
+
const ext = filename.substring(
|
|
136
|
+
filename.lastIndexOf(".") + 1,
|
|
137
|
+
filename.length
|
|
139
138
|
);
|
|
139
|
+
if (filename === ext) return undefined;
|
|
140
|
+
return ext;
|
|
140
141
|
};
|
|
141
142
|
|
|
142
143
|
export const fileBelongsInPagesFolder = (filename: string) => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"categorizeFiles.js","sourceRoot":"","sources":["../../../src/local-preview/listener/categorizeFiles.ts"],"names":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G,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;oBAC3C,YAAY,CAAC,IAAI,CAAC;wBAChB,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;wBAC1D,IAAI,EAAE,WAAW,CAAC,IAAI;qBACvB,CAAC,CAAC;iBACJ;aACF;iBAAM,IACL,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC;gBACrC,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;gBAClC,CAAC,SAAS,EACV;gBACA,kBAAkB;gBAClB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAChC;QACH,CAAC,CAAC,EAAE,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE5B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AACvE,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import pathUtil from "path";
|
|
2
|
-
export const fileIsMdxOrMd = (filename) => {
|
|
3
|
-
try {
|
|
4
|
-
const extension = pathUtil.parse(filename).ext;
|
|
5
|
-
return extension && (extension === ".mdx" || extension === ".md");
|
|
6
|
-
}
|
|
7
|
-
catch (e) {
|
|
8
|
-
// TypeError when filename is not a string
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=fileIsMdxOrMd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileIsMdxOrMd.js","sourceRoot":"","sources":["../../../../src/local-preview/listener/utils/fileIsMdxOrMd.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,MAAM,CAAC;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,EAAE;IAChD,IAAI;QACF,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC;QAC/C,OAAO,SAAS,IAAI,CAAC,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,KAAK,CAAC,CAAC;KACnE;IAAC,OAAO,CAAC,EAAE;QACV,0CAA0C;QAC1C,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { promises as _promises } from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { CMD_EXEC_PATH } from "../../constants.js";
|
|
4
|
-
import openApiCheck from "./openApiCheck.js";
|
|
5
|
-
import { getFileExtension } from "../../util.js";
|
|
6
|
-
const { readdir } = _promises;
|
|
7
|
-
const getFileList = async (dirName, og = dirName) => {
|
|
8
|
-
let files = [];
|
|
9
|
-
const items = await readdir(dirName, { withFileTypes: true });
|
|
10
|
-
for (const item of items) {
|
|
11
|
-
if (item.isDirectory()) {
|
|
12
|
-
files = [...files, ...(await getFileList(`${dirName}/${item.name}`, og))];
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
const path = `${dirName}/${item.name}`;
|
|
16
|
-
const name = path.replace(og, "");
|
|
17
|
-
files.push({ path, isSymbolicLink: item.isSymbolicLink(), name });
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return files;
|
|
21
|
-
};
|
|
22
|
-
const categorizeFiles = async () => {
|
|
23
|
-
const allFilesInCmdExecutionPath = await getFileList(CMD_EXEC_PATH);
|
|
24
|
-
const markdownFiles = [];
|
|
25
|
-
const staticFiles = [];
|
|
26
|
-
const promises = [];
|
|
27
|
-
const openApiFiles = [];
|
|
28
|
-
allFilesInCmdExecutionPath.forEach((file) => {
|
|
29
|
-
promises.push((async () => {
|
|
30
|
-
const extension = getFileExtension(file.name);
|
|
31
|
-
let isOpenApi = false;
|
|
32
|
-
if (extension &&
|
|
33
|
-
(extension === "mdx" || extension === "md" || extension === "tsx")) {
|
|
34
|
-
markdownFiles.push(file.name);
|
|
35
|
-
}
|
|
36
|
-
else if (extension &&
|
|
37
|
-
(extension === "json" || extension === "yaml" || extension === "yml")) {
|
|
38
|
-
const openApiInfo = await openApiCheck(path.join(CMD_EXEC_PATH, file.name));
|
|
39
|
-
isOpenApi = openApiInfo.isOpenApi;
|
|
40
|
-
if (isOpenApi) {
|
|
41
|
-
const fileName = path.parse(file.name).base;
|
|
42
|
-
openApiFiles.push({
|
|
43
|
-
name: fileName.substring(0, fileName.lastIndexOf(".")),
|
|
44
|
-
openapi: openApiInfo.openapi,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else if ((!file.name.endsWith("mint.config.json") ||
|
|
49
|
-
!file.name.endsWith("mint.json")) &&
|
|
50
|
-
!isOpenApi) {
|
|
51
|
-
// all other files
|
|
52
|
-
staticFiles.push(file.name);
|
|
53
|
-
}
|
|
54
|
-
})());
|
|
55
|
-
});
|
|
56
|
-
await Promise.all(promises);
|
|
57
|
-
const openApi = {
|
|
58
|
-
files: openApiFiles,
|
|
59
|
-
};
|
|
60
|
-
return { markdownFiles, staticFiles, openApi };
|
|
61
|
-
};
|
|
62
|
-
export default categorizeFiles;
|
|
63
|
-
//# sourceMappingURL=categorizeFiles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"categorizeFiles.js","sourceRoot":"","sources":["../../../src/local-preview/utils/categorizeFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAA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EF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AACjD,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
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();
|
|
10
|
-
return {
|
|
11
|
-
method: foundMethod ? foundMethod[0].slice(0, -1).toUpperCase() : undefined,
|
|
12
|
-
endpoint: api.substring(endIndexOfMethod).trim(),
|
|
13
|
-
filename: filename ? filename : undefined,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export const getOpenApiOperationMethodAndEndpoint = (openApi, openApiMetaField) => {
|
|
17
|
-
var _a;
|
|
18
|
-
const { endpoint, method, filename } = extractMethodAndEndpoint(openApiMetaField);
|
|
19
|
-
let path;
|
|
20
|
-
(_a = openApi.files) === null || _a === void 0 ? void 0 : _a.forEach((file) => {
|
|
21
|
-
const openApiFile = file.openapi;
|
|
22
|
-
const openApiPath = openApiFile.paths && openApiFile.paths[endpoint];
|
|
23
|
-
const isFilenameOrNone = !filename || filename === file.name;
|
|
24
|
-
if (openApiPath && isFilenameOrNone) {
|
|
25
|
-
path = openApiPath;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
if (path == null) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
let operation;
|
|
32
|
-
if (method) {
|
|
33
|
-
operation = path[method.toLowerCase()];
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const firstOperationKey = Object.keys(path)[0];
|
|
37
|
-
operation = path[firstOperationKey];
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
operation,
|
|
41
|
-
method,
|
|
42
|
-
endpoint,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
export const getOpenApiTitleAndDescription = (openApi, openApiMetaField) => {
|
|
46
|
-
if (openApi == null || !openApiMetaField || openApiMetaField == null) {
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
const { operation } = getOpenApiOperationMethodAndEndpoint(openApi, openApiMetaField);
|
|
50
|
-
if (operation == null) {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
title: operation.summary,
|
|
55
|
-
description: operation.description,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=getOpenApiContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getOpenApiContext.js","sourceRoot":"","sources":["../../../src/local-preview/utils/getOpenApiContext.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,GAAW,EAC+C,EAAE;IAC5D,MAAM,WAAW,GAAG,gCAAgC,CAAC;IACrD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE/C,MAAM,kBAAkB,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,WAAW;QAClC,CAAC,CAAC,kBAAkB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;QAChD,CAAC,CAAC,CAAC,CAAC;IAEN,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,IA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AC;QAC/C,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC;KACrC;IAED,OAAO;QACL,SAAS;QACT,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE;IACzE,IAAI,OAAO,IAAI,IAAI,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,IAAI,IAAI,EAAE;QACpE,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,oCAAoC,CACxD,OAAO,EACP,gBAAgB,CACjB,CAAC;IAEF,IAAI,SAAS,IAAI,IAAI,EAAE;QACrB,OAAO,EAAE,CAAC;KACX;IAED,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,OAAO;QACxB,WAAW,EAAE,SAAS,CAAC,WAAW;KACnC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import favicons from "favicons";
|
|
2
|
-
import { promises as _promises } from "fs";
|
|
3
|
-
import { outputFile } from "fs-extra";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
import { CLIENT_PATH, CMD_EXEC_PATH } from "../../constants.js";
|
|
6
|
-
const { readFile } = _promises;
|
|
7
|
-
export const injectFavicons = async (configObj, logger) => {
|
|
8
|
-
if ((configObj === null || configObj === void 0 ? void 0 : configObj.favicon) == null)
|
|
9
|
-
return;
|
|
10
|
-
const desiredPath = join(CMD_EXEC_PATH, configObj.favicon);
|
|
11
|
-
const favicon = await readFile(desiredPath);
|
|
12
|
-
if (favicon == null)
|
|
13
|
-
return;
|
|
14
|
-
logger.start("Generating favicons...");
|
|
15
|
-
const promises = [];
|
|
16
|
-
try {
|
|
17
|
-
const response = await favicons(favicon, faviconConfig(configObj === null || configObj === void 0 ? void 0 : configObj.name));
|
|
18
|
-
response.images.forEach((img) => {
|
|
19
|
-
promises.push((async () => {
|
|
20
|
-
const targetPath = join(CLIENT_PATH, "public", "favicons", img.name);
|
|
21
|
-
await outputFile(targetPath, Buffer.from(img.contents), {
|
|
22
|
-
flag: "w",
|
|
23
|
-
});
|
|
24
|
-
})());
|
|
25
|
-
});
|
|
26
|
-
response.files.forEach((file) => {
|
|
27
|
-
promises.push((async () => {
|
|
28
|
-
const targetPath = join(CLIENT_PATH, "public", "favicons", file.name);
|
|
29
|
-
await outputFile(targetPath, file.contents, { flag: "w" });
|
|
30
|
-
})());
|
|
31
|
-
});
|
|
32
|
-
await Promise.all(promises);
|
|
33
|
-
logger.succeed("Favicons generated");
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
console.log(err.message); // Error description e.g. "An unknown error has occurred"
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const faviconConfig = (name) => ({
|
|
40
|
-
path: "/favicons",
|
|
41
|
-
appName: name,
|
|
42
|
-
appShortName: name,
|
|
43
|
-
appDescription: null,
|
|
44
|
-
developerName: null,
|
|
45
|
-
developerURL: null,
|
|
46
|
-
dir: "auto",
|
|
47
|
-
lang: "en-US",
|
|
48
|
-
background: "#fff",
|
|
49
|
-
theme_color: "#fff",
|
|
50
|
-
appleStatusBarStyle: "black-translucent",
|
|
51
|
-
display: "standalone",
|
|
52
|
-
orientation: "any",
|
|
53
|
-
scope: "/",
|
|
54
|
-
start_url: "/?homescreen=1",
|
|
55
|
-
preferRelatedApplications: false,
|
|
56
|
-
relatedApplications: undefined,
|
|
57
|
-
version: "1.0",
|
|
58
|
-
logging: false,
|
|
59
|
-
pixel_art: false,
|
|
60
|
-
loadManifestWithCredentials: true,
|
|
61
|
-
manifestMaskable: false,
|
|
62
|
-
icons: {
|
|
63
|
-
android: ["android-chrome-192x192.png", "android-chrome-256x256.png"],
|
|
64
|
-
appleIcon: ["apple-touch-icon.png"],
|
|
65
|
-
appleStartup: false,
|
|
66
|
-
favicons: true,
|
|
67
|
-
windows: ["mstile-150x150.png"],
|
|
68
|
-
yandex: false,
|
|
69
|
-
firefox: false,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
//# sourceMappingURL=injectFavicons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectFavicons.js","sourceRoot":"","sources":["../../../src/local-preview/utils/injectFavicons.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;AAE/B,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;IACxD,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,KAAI,IAAI;QAAE,OAAO;IAEvC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO;IAC5B,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC,CAAC,CAAC;QACzE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC9B,QAAQ,CAAC,IAAI,CACX,CAAC,KAAK,IAAI,EAAE;gBACV,MAAM,UAAU,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