mintlify 1.0.6 → 1.0.8
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/README.md +27 -3
- package/bin/browser.js +24 -0
- package/bin/browser.js.map +1 -0
- package/bin/constants.js +8 -0
- package/bin/constants.js.map +1 -0
- package/bin/dev/getOpenApiContext.js +46 -0
- package/bin/dev/getOpenApiContext.js.map +1 -0
- package/bin/dev/index.js +164 -0
- package/bin/dev/index.js.map +1 -0
- package/bin/dev/injectNav.js +97 -0
- package/bin/dev/injectNav.js.map +1 -0
- package/bin/dev/slugToTitle.js +8 -0
- package/bin/dev/slugToTitle.js.map +1 -0
- package/bin/downloadImage.js +27 -0
- package/bin/downloadImage.js.map +1 -0
- package/bin/index.js +49 -106
- package/bin/index.js.map +1 -1
- package/bin/init-command/index.js +51 -0
- package/bin/init-command/index.js.map +1 -0
- package/bin/init-command/templates.js +41 -0
- package/bin/init-command/templates.js.map +1 -0
- package/bin/local-preview/categorizeFiles.js +56 -0
- package/bin/local-preview/categorizeFiles.js.map +1 -0
- package/bin/local-preview/getOpenApiContext.js +46 -0
- package/bin/local-preview/getOpenApiContext.js.map +1 -0
- package/bin/local-preview/index.js +138 -0
- package/bin/local-preview/index.js.map +1 -0
- package/bin/local-preview/injectFavicons.js +72 -0
- package/bin/local-preview/injectFavicons.js.map +1 -0
- package/bin/local-preview/listener.js +112 -0
- package/bin/local-preview/listener.js.map +1 -0
- package/bin/local-preview/metadata.js +121 -0
- package/bin/local-preview/metadata.js.map +1 -0
- package/bin/local-preview/mintConfigFile.js +43 -0
- package/bin/local-preview/mintConfigFile.js.map +1 -0
- package/bin/local-preview/openApiCheck.js +16 -0
- package/bin/local-preview/openApiCheck.js.map +1 -0
- package/bin/local-preview/slugToTitle.js +8 -0
- package/bin/local-preview/slugToTitle.js.map +1 -0
- package/bin/mint/client/.babel-plugin-macrosrc.json +5 -0
- package/bin/mint/client/.babelrc +4 -0
- package/bin/mint/client/.editorconfig +12 -0
- package/bin/mint/client/.eslintrc.json +7 -0
- package/bin/mint/client/.prettierignore +4 -0
- package/bin/mint/client/.prettierrc +14 -0
- package/bin/mint/client/.vscode/launch.json +28 -0
- package/bin/mint/client/README.md +46 -0
- package/bin/mint/client/jest.config.ts +195 -0
- package/bin/mint/client/next-env.d.ts +4 -0
- package/bin/mint/client/next.config.js +152 -0
- package/bin/mint/client/package.json +140 -0
- package/bin/mint/client/postcss.config.cjs +9 -0
- package/bin/mint/client/prebuild/faviconConfig.js +35 -0
- package/bin/mint/client/prebuild/getOpenApiContext.js +53 -0
- package/bin/mint/client/prebuild/index.js +117 -0
- package/bin/mint/client/prebuild/injectNav.js +115 -0
- package/bin/mint/client/prebuild/slugToTitle.js +7 -0
- package/bin/mint/client/rehype/withApiComponents.js +60 -0
- package/bin/mint/client/rehype/withCodeBlocks.js +54 -0
- package/bin/mint/client/rehype/withLayouts.js +113 -0
- package/bin/mint/client/rehype/withLinkRoles.js +13 -0
- package/bin/mint/client/rehype/withRawComponents.js +13 -0
- package/bin/mint/client/rehype/withStaticProps.js +25 -0
- package/bin/mint/client/rehype/withSyntaxHighlighting.js +60 -0
- package/bin/mint/client/remark/utils.js +369 -0
- package/bin/mint/client/remark/withFrames.js +55 -0
- package/bin/mint/client/remark/withImportsInjected.js +36 -0
- package/bin/mint/client/remark/withNextLinks.js +37 -0
- package/bin/mint/client/remark/withTableOfContents.js +71 -0
- package/bin/mint/client/scripts/local-to-docs.js +72 -0
- package/bin/mint/client/scripts/local.js +177 -0
- package/bin/mint/client/sentry.client.config.js +15 -0
- package/bin/mint/client/sentry.properties +4 -0
- package/bin/mint/client/sentry.server.config.js +15 -0
- package/bin/mint/client/src/analytics/AbstractAnalyticsImplementation.ts +50 -0
- package/bin/mint/client/src/analytics/AnalyticsContext.ts +5 -0
- package/bin/mint/client/src/analytics/AnalyticsMediator.ts +101 -0
- package/bin/mint/client/src/analytics/FakeAnalyticsMediator.ts +9 -0
- package/bin/mint/client/src/analytics/GA4Script.tsx +33 -0
- package/bin/mint/client/src/analytics/implementations/amplitude.ts +26 -0
- package/bin/mint/client/src/analytics/implementations/fathom.ts +38 -0
- package/bin/mint/client/src/analytics/implementations/ga4.ts +33 -0
- package/bin/mint/client/src/analytics/implementations/hotjar.ts +53 -0
- package/bin/mint/client/src/analytics/implementations/mixpanel-browser.d.ts +1 -0
- package/bin/mint/client/src/analytics/implementations/mixpanel.ts +52 -0
- package/bin/mint/client/src/analytics/implementations/posthog.ts +37 -0
- package/bin/mint/client/src/components/Accordion/Accordion.tsx +43 -0
- package/bin/mint/client/src/components/Accordion/index.ts +4 -0
- package/bin/mint/client/src/components/ApiExample.tsx +9 -0
- package/bin/mint/client/src/components/Card.tsx +51 -0
- package/bin/mint/client/src/components/CodeGroup.tsx +132 -0
- package/bin/mint/client/src/components/Editor.tsx +12 -0
- package/bin/mint/client/src/components/Expandable.tsx +40 -0
- package/bin/mint/client/src/components/Heading.tsx +84 -0
- package/bin/mint/client/src/components/Param.tsx +56 -0
- package/bin/mint/client/src/components/Request.tsx +19 -0
- package/bin/mint/client/src/components/ResponseField.tsx +33 -0
- package/bin/mint/client/src/components/TabBar.tsx +61 -0
- package/bin/mint/client/src/config.ts +115 -0
- package/bin/mint/client/src/css/bar-of-progress.css +10 -0
- package/bin/mint/client/src/css/base.css +29 -0
- package/bin/mint/client/src/css/font-awesome.css +7 -0
- package/bin/mint/client/src/css/fonts.css +44 -0
- package/bin/mint/client/src/css/main.css +11 -0
- package/bin/mint/client/src/css/prism.css +270 -0
- package/bin/mint/client/src/css/utilities.css +43 -0
- package/bin/mint/client/src/enums/components.ts +8 -0
- package/bin/mint/client/src/fonts/FiraCode-VF.woff +0 -0
- package/bin/mint/client/src/fonts/FiraCode-VF.woff2 +0 -0
- package/bin/mint/client/src/fonts/IBMPlexMono-Regular.ttf +0 -0
- package/bin/mint/client/src/fonts/IBMPlexMono-SemiBold.ttf +0 -0
- package/bin/mint/client/src/fonts/Inter-italic-latin.var.woff2 +0 -0
- package/bin/mint/client/src/fonts/Inter-roman-latin.var.woff2 +0 -0
- package/bin/mint/client/src/fonts/Pally-Variable.ttf +0 -0
- package/bin/mint/client/src/fonts/SourceSansPro-Regular.otf +0 -0
- package/bin/mint/client/src/fonts/SourceSerifPro-Regular.ttf +0 -0
- package/bin/mint/client/src/fonts/Synonym-Variable.ttf +0 -0
- package/bin/mint/client/src/fonts/Ubuntu-Mono-bold.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-Regular.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/IBMPlexMono-SemiBold.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/Pally-Variable-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/Pally-Variable.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/SourceSerifPro-Regular.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/Synonym-Variable-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/Synonym-Variable.module.css +11 -0
- package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.woff2 +0 -0
- package/bin/mint/client/src/fonts/generated/TenorSans-Regular-subset.zopfli.woff +0 -0
- package/bin/mint/client/src/fonts/generated/TenorSans-Regular.module.css +11 -0
- package/bin/mint/client/src/hooks/useActionKey.ts +20 -0
- package/bin/mint/client/src/hooks/useIsomorphicLayoutEffect.ts +3 -0
- package/bin/mint/client/src/hooks/useMedia.ts +27 -0
- package/bin/mint/client/src/hooks/usePrevNext.ts +34 -0
- package/bin/mint/client/src/hooks/useTop.ts +15 -0
- package/bin/mint/client/src/icons/CopyToClipboard.tsx +33 -0
- package/bin/mint/client/src/index.d.ts +1 -0
- package/bin/mint/client/src/layouts/ApiSupplemental.tsx +173 -0
- package/bin/mint/client/src/layouts/ContentsLayout.tsx +256 -0
- package/bin/mint/client/src/layouts/DocumentationLayout.tsx +44 -0
- package/bin/mint/client/src/layouts/OpenApiContent.tsx +301 -0
- package/bin/mint/client/src/layouts/SidebarLayout.tsx +412 -0
- package/bin/mint/client/src/layouts/UserFeedback.tsx +73 -0
- package/bin/mint/client/src/layouts/getGroupsInDivision.ts +25 -0
- package/bin/mint/client/src/layouts/isPathInGroupPages.ts +10 -0
- package/bin/mint/client/src/metadata.ts +58 -0
- package/bin/mint/client/src/openapi.ts +3 -0
- package/bin/mint/client/src/pages/404.tsx +73 -0
- package/bin/mint/client/src/pages/_app.tsx +138 -0
- package/bin/mint/client/src/pages/_document.tsx +57 -0
- package/bin/mint/client/src/pages/api/issue.ts +10 -0
- package/bin/mint/client/src/pages/api/name.ts +8 -0
- package/bin/mint/client/src/pages/api/request.ts +31 -0
- package/bin/mint/client/src/pages/api/suggest.ts +10 -0
- package/bin/mint/client/src/pages/api/syntax-highlighted-json.ts +13 -0
- package/bin/mint/client/src/pages/api/utils.ts +6 -0
- package/bin/mint/client/src/pages/index.tsx +31 -0
- package/bin/mint/client/src/ui/Api.tsx +359 -0
- package/bin/mint/client/src/ui/Footer.tsx +124 -0
- package/bin/mint/client/src/ui/Header.tsx +370 -0
- package/bin/mint/client/src/ui/Logo.tsx +55 -0
- package/bin/mint/client/src/ui/PageHeader.tsx +51 -0
- package/bin/mint/client/src/ui/Search.tsx +386 -0
- package/bin/mint/client/src/ui/ThemeToggle.tsx +285 -0
- package/bin/mint/client/src/ui/Title.tsx +22 -0
- package/bin/mint/client/src/ui/TopLevelLink.tsx +122 -0
- package/bin/mint/client/src/utils/api.ts +252 -0
- package/bin/mint/client/src/utils/brands.ts +217 -0
- package/bin/mint/client/src/utils/castArray.ts +3 -0
- package/bin/mint/client/src/utils/childrenArray.ts +3 -0
- package/bin/mint/client/src/utils/fit.ts +27 -0
- package/bin/mint/client/src/utils/fontAwesome.ts +577 -0
- package/bin/mint/client/src/utils/getAnalyticsConfig.ts +14 -0
- package/bin/mint/client/src/utils/getLogoHref.ts +9 -0
- package/bin/mint/client/src/utils/getOpenApiContext.ts +26 -0
- package/bin/mint/client/src/utils/importAll.ts +6 -0
- package/bin/mint/client/src/utils/isObject.ts +3 -0
- package/bin/mint/client/src/utils/kebabToTitleCase.ts +3 -0
- package/bin/mint/client/src/utils/loadImage.ts +8 -0
- package/bin/mint/client/src/utils/slugToTitle.ts +7 -0
- package/bin/mint/client/src/utils/wait.ts +5 -0
- package/bin/mint/client/tailwind.config.cjs +323 -0
- package/bin/mint/client/test/test.test.ts +5 -0
- package/bin/mint/client/tsconfig.json +36 -0
- package/bin/mint/client/yarn.lock +9702 -0
- package/bin/navigation.js +4 -0
- package/bin/navigation.js.map +1 -0
- package/bin/pageTemplate.js +30 -0
- package/bin/pageTemplate.js.map +1 -0
- package/bin/scraping/combineNavWithEmptyGroupTitles.js +20 -0
- package/bin/scraping/combineNavWithEmptyGroupTitles.js.map +1 -0
- package/bin/scraping/detectFramework.js +25 -0
- package/bin/scraping/detectFramework.js.map +1 -0
- package/bin/scraping/downloadAllImages.js +57 -0
- package/bin/scraping/downloadAllImages.js.map +1 -0
- package/bin/scraping/getSitemapLinks.js +18 -0
- package/bin/scraping/getSitemapLinks.js.map +1 -0
- package/bin/scraping/replaceImagePaths.js +17 -0
- package/bin/scraping/replaceImagePaths.js.map +1 -0
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +43 -0
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +1 -0
- package/bin/scraping/scrapeGettingFileNameFromUrl.js +14 -0
- package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +1 -0
- package/bin/scraping/scrapePage.js +9 -0
- package/bin/scraping/scrapePage.js.map +1 -0
- package/bin/scraping/scrapePageCommands.js +48 -0
- package/bin/scraping/scrapePageCommands.js.map +1 -0
- package/bin/scraping/scrapeSection.js +9 -0
- package/bin/scraping/scrapeSection.js.map +1 -0
- package/bin/scraping/scrapeSectionCommands.js +90 -0
- package/bin/scraping/scrapeSectionCommands.js.map +1 -0
- package/bin/scraping/site-scrapers/getLinksRecursively.js +33 -0
- package/bin/scraping/site-scrapers/getLinksRecursively.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js +43 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +52 -0
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -0
- package/bin/{scrapeGitBookPage.js → scraping/site-scrapers/scrapeGitBookPage.js} +10 -5
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +51 -0
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeReadMePage.js +35 -0
- package/bin/scraping/site-scrapers/scrapeReadMePage.js.map +1 -0
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js +38 -0
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +1 -0
- package/bin/util.js +47 -8
- package/bin/util.js.map +1 -1
- package/bin/validation/isValidLink.js +11 -0
- package/bin/validation/isValidLink.js.map +1 -0
- package/bin/validation/stopIfInvalidLink.js +9 -0
- package/bin/validation/stopIfInvalidLink.js.map +1 -0
- package/package.json +21 -4
- package/src/browser.ts +24 -0
- package/src/constants.ts +10 -0
- package/src/downloadImage.ts +35 -0
- package/src/index.ts +111 -122
- package/src/init-command/index.ts +59 -0
- package/src/{templates.ts → init-command/templates.ts} +0 -0
- package/src/local-preview/categorizeFiles.ts +74 -0
- package/src/local-preview/getOpenApiContext.ts +61 -0
- package/src/local-preview/index.ts +164 -0
- package/src/local-preview/injectFavicons.ts +76 -0
- package/src/local-preview/listener.ts +116 -0
- package/src/local-preview/metadata.ts +154 -0
- package/src/local-preview/mintConfigFile.ts +48 -0
- package/src/local-preview/openApiCheck.ts +19 -0
- package/src/local-preview/slugToTitle.ts +7 -0
- package/src/navigation.ts +12 -0
- package/src/pageTemplate.ts +32 -0
- package/src/scraping/combineNavWithEmptyGroupTitles.ts +21 -0
- package/src/scraping/detectFramework.ts +31 -0
- package/src/scraping/downloadAllImages.ts +79 -0
- package/src/scraping/getSitemapLinks.ts +18 -0
- package/src/scraping/replaceImagePaths.ts +21 -0
- package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +81 -0
- package/src/scraping/scrapeGettingFileNameFromUrl.ts +50 -0
- package/src/scraping/scrapePage.ts +24 -0
- package/src/scraping/scrapePageCommands.ts +52 -0
- package/src/scraping/scrapeSection.ts +16 -0
- package/src/scraping/scrapeSectionCommands.ts +110 -0
- package/src/scraping/site-scrapers/getLinksRecursively.ts +40 -0
- package/src/scraping/site-scrapers/scrapeDocusaurusPage.ts +67 -0
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +80 -0
- package/src/{scrapeGitBookPage.ts → scraping/site-scrapers/scrapeGitBookPage.ts} +25 -5
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +77 -0
- package/src/scraping/site-scrapers/scrapeReadMePage.ts +57 -0
- package/src/scraping/site-scrapers/scrapeReadMeSection.ts +60 -0
- package/src/util.ts +53 -7
- package/src/validation/isValidLink.ts +9 -0
- package/src/validation/stopIfInvalidLink.ts +9 -0
- package/tsconfig.json +1 -1
- package/bin/scrapeGitBook.js +0 -28
- package/bin/scrapeGitBook.js.map +0 -1
- package/bin/scrapeGitBookPage.js.map +0 -1
- package/bin/scrapeReadMe.js +0 -60
- package/bin/scrapeReadMe.js.map +0 -1
- package/bin/scrapeReadMePage.js +0 -28
- package/bin/scrapeReadMePage.js.map +0 -1
- package/src/scrapeReadMe.ts +0 -79
- package/src/scrapeReadMePage.ts +0 -37
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
1
|
import cheerio from "cheerio";
|
|
3
2
|
import { NodeHtmlMarkdown } from "node-html-markdown";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import downloadAllImages from "../downloadAllImages.js";
|
|
4
|
+
import replaceImagePaths from "../replaceImagePaths.js";
|
|
5
|
+
export async function scrapeGitBookPage(html, origin, cliDir, imageBaseDir) {
|
|
6
|
+
const $ = cheerio.load(html);
|
|
7
7
|
const titleComponent = $('[data-testid="page.title"]').first();
|
|
8
8
|
const titleAndDescription = titleComponent.parent().parent().parent().text();
|
|
9
|
-
console.log(titleAndDescription);
|
|
10
9
|
const description = titleAndDescription
|
|
11
10
|
.replace(titleComponent.text(), "")
|
|
12
11
|
.trim();
|
|
13
12
|
const title = titleComponent.text().trim();
|
|
14
13
|
const content = $('[data-testid="page.contentEditor"]').first();
|
|
15
14
|
const contentHtml = $.html(content);
|
|
15
|
+
const modifyFileName = (fileName) =>
|
|
16
|
+
// Remove GitBook metadata from the start
|
|
17
|
+
// The first four %2F split metadata fields. Remaining ones are part of the file name.
|
|
18
|
+
fileName.split("%2F").slice(4).join("%2F");
|
|
19
|
+
const origToWritePath = await downloadAllImages($, content, origin, imageBaseDir, modifyFileName);
|
|
16
20
|
const nhm = new NodeHtmlMarkdown();
|
|
17
21
|
let markdown = nhm.translate(contentHtml);
|
|
18
22
|
// Keep headers on one line and increase their depth by one
|
|
@@ -23,6 +27,7 @@ export async function scrapeGitBookPage(url) {
|
|
|
23
27
|
markdown = markdown.replace(/\n\n\n/g, "\n\n");
|
|
24
28
|
// Mintlify doesn't support bolded headers, remove the asterisks
|
|
25
29
|
markdown = markdown.replace(/(\n#+) \*\*(.*)\*\*\n/g, "$1 $2\n");
|
|
30
|
+
markdown = replaceImagePaths(origToWritePath, cliDir, markdown);
|
|
26
31
|
return { title, description, markdown };
|
|
27
32
|
}
|
|
28
33
|
//# sourceMappingURL=scrapeGitBookPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrapeGitBookPage.js","sourceRoot":"","sources":["../../../src/scraping/site-scrapers/scrapeGitBookPage.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,MAAc,EACd,MAAc,EACd,YAAoB;IAEpB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,cAAc,GAAG,CAAC,CAAC,4BAA4B,CAAC,CAAC,KAAK,EAAE,CAAC;IAC/D,MAAM,mBAAmB,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,WAAW,GAAG,mBAAmB;SACpC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC;SAClC,IAAI,EAAE,CAAC;IACV,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IAE3C,MAAM,OAAO,GAAG,CAAC,CAAC,oCAAoC,CAAC,CAAC,KAAK,EAAE,CAAC;IAChE,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEpC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,EAAE;IAClC,yCAAyC;IACzC,sFAAsF;IACtF,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAC7C,CAAC,EACD,OAAO,EACP,MAAM,EACN,YAAY,EACZ,cAAc,CACf,CAAC;IAEF,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACnC,IAAI,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,2DAA2D;IAC3D,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE9C,qDAAqD;IACrD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAE3C,iCAAiC;IACjC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE/C,gEAAgE;IAChE,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;IAEjE,QAAQ,GAAG,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEhE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import cheerio from "cheerio";
|
|
2
|
+
import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js";
|
|
3
|
+
import { scrapeGitBookPage } from "./scrapeGitBookPage.js";
|
|
4
|
+
import combineNavWithEmptyGroupTitles from "../combineNavWithEmptyGroupTitles.js";
|
|
5
|
+
import getLinksRecursively from "./getLinksRecursively.js";
|
|
6
|
+
export async function scrapeGitBookSection(html, origin, cliDir, overwrite) {
|
|
7
|
+
const $ = cheerio.load(html);
|
|
8
|
+
// Get all the navigation sections
|
|
9
|
+
const navigationSections = $('div[data-testid="page.desktopTableOfContents"] > div > div:first-child')
|
|
10
|
+
.children()
|
|
11
|
+
.first()
|
|
12
|
+
.children()
|
|
13
|
+
.first()
|
|
14
|
+
.children();
|
|
15
|
+
// Get all links per group
|
|
16
|
+
const groupsConfig = navigationSections
|
|
17
|
+
.map((i, s) => {
|
|
18
|
+
const section = $(s);
|
|
19
|
+
const sectionTitle = $(section)
|
|
20
|
+
.find('div > div[dir="auto"]')
|
|
21
|
+
.first()
|
|
22
|
+
.text();
|
|
23
|
+
// Only present if the nested navigation is not in a group
|
|
24
|
+
const firstLink = section.children().eq(0);
|
|
25
|
+
const firstHref = firstLink.attr("href");
|
|
26
|
+
const linkSections = section.children().eq(1).children();
|
|
27
|
+
const pages = getLinksRecursively(linkSections, $);
|
|
28
|
+
return {
|
|
29
|
+
group: sectionTitle || alternateTitle(firstLink, pages),
|
|
30
|
+
pages: firstHref ? [firstHref, ...pages] : pages,
|
|
31
|
+
};
|
|
32
|
+
})
|
|
33
|
+
.toArray()
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
// Merge groups with empty titles together
|
|
36
|
+
const reducedGroupsConfig = combineNavWithEmptyGroupTitles(groupsConfig);
|
|
37
|
+
// Scrape each link in the navigation.
|
|
38
|
+
const groupsConfigCleanPaths = await Promise.all(reducedGroupsConfig.map(async (navEntry) => {
|
|
39
|
+
return await scrapeGettingFileNameFromUrl(navEntry, cliDir, origin, overwrite, scrapeGitBookPage, true);
|
|
40
|
+
}));
|
|
41
|
+
return groupsConfigCleanPaths;
|
|
42
|
+
}
|
|
43
|
+
function alternateTitle(firstLink, pages) {
|
|
44
|
+
// Only assign titles to nested navigation menus outside a section.
|
|
45
|
+
// Others should not have a title so we can merge them into one section.
|
|
46
|
+
if (pages.length > 0) {
|
|
47
|
+
return firstLink === null || firstLink === void 0 ? void 0 : firstLink.text();
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=scrapeGitBookSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrapeGitBookSection.js","sourceRoot":"","sources":["../../../src/scraping/site-scrapers/scrapeGitBookSection.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,8BAA8B,MAAM,sCAAsC,CAAC;AAClF,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAY,EACZ,MAAc,EACd,MAAc,EACd,SAAkB;IAElB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7B,kCAAkC;IAClC,MAAM,kBAAkB,GAAG,CAAC,CAC1B,wEAAwE,CACzE;SACE,QAAQ,EAAE;SACV,KAAK,EAAE;SACP,QAAQ,EAAE;SACV,KAAK,EAAE;SACP,QAAQ,EAAE,CAAC;IAEd,0BAA0B;IAC1B,MAAM,YAAY,GAAG,kBAAkB;SACpC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC;aAC5B,IAAI,CAAC,uBAAuB,CAAC;aAC7B,KAAK,EAAE;aACP,IAAI,EAAE,CAAC;QAEV,0DAA0D;QAC1D,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,KAAK,GAAG,mBAAmB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAEnD,OAAO;YACL,KAAK,EAAE,YAAY,IAAI,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC;YACvD,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;SACjD,CAAC;IACJ,CAAC,CAAC;SACD,OAAO,EAAE;SACT,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,0CAA0C;IAC1C,MAAM,mBAAmB,GAAG,8BAA8B,CAAC,YAAY,CAAC,CAAC;IAEzE,sCAAsC;IACtC,MAAM,sBAAsB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9C,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,QAAyB,EAAE,EAAE;QAC1D,OAAO,MAAM,4BAA4B,CACvC,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,IAAI,CACL,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,SAAS,EAAE,KAAK;IACtC,mEAAmE;IACnE,wEAAwE;IACxE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,OAAO,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,EAAE,CAAC;KAC1B;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import cheerio from "cheerio";
|
|
2
|
+
import { NodeHtmlMarkdown } from "node-html-markdown";
|
|
3
|
+
import downloadAllImages from "../downloadAllImages.js";
|
|
4
|
+
import replaceImagePaths from "../replaceImagePaths.js";
|
|
5
|
+
export async function scrapeReadMePage(html, origin, cliDir, imageBaseDir) {
|
|
6
|
+
const $ = cheerio.load(html);
|
|
7
|
+
const titleComponent = $("h1").first();
|
|
8
|
+
const title = titleComponent.text().trim();
|
|
9
|
+
let description = $(".markdown-body", titleComponent.parent()).text().trim();
|
|
10
|
+
if (!description) {
|
|
11
|
+
description = $(".rm-Article > header p").text().trim();
|
|
12
|
+
}
|
|
13
|
+
let content = $(".content-body .markdown-body").first();
|
|
14
|
+
if (content.length === 0) {
|
|
15
|
+
content = $(".rm-Article > .markdown-body");
|
|
16
|
+
}
|
|
17
|
+
// API Pages don't have a markdown body in the same position so there's no HTML
|
|
18
|
+
let contentHtml = content.html() || "";
|
|
19
|
+
const origToWritePath = await downloadAllImages($, content, origin, imageBaseDir);
|
|
20
|
+
const nhm = new NodeHtmlMarkdown();
|
|
21
|
+
let markdown = nhm.translate(contentHtml);
|
|
22
|
+
// Keep headers on one line and increase their depth by one
|
|
23
|
+
markdown = markdown.replace(/# \n\n/g, "## ");
|
|
24
|
+
// Remove unnecessary nonwidth blank space characters
|
|
25
|
+
markdown = markdown.replace(/\u200b/g, "");
|
|
26
|
+
// Remove ReadMe anchor links
|
|
27
|
+
markdown = markdown.replace(/\n\[\]\(#.+\)\n/g, "\n");
|
|
28
|
+
// Reduce unnecessary blank lines
|
|
29
|
+
markdown = markdown.replace(/\n\n\n/g, "\n\n");
|
|
30
|
+
// Mintlify doesn't support bolded headers, remove the asterisks
|
|
31
|
+
markdown = markdown.replace(/(\n#+) \*\*(.*)\*\*\n/g, "$1 $2\n");
|
|
32
|
+
markdown = replaceImagePaths(origToWritePath, cliDir, markdown);
|
|
33
|
+
return { title, description, markdown };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=scrapeReadMePage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrapeReadMePage.js","sourceRoot":"","sources":["../../../src/scraping/site-scrapers/scrapeReadMePage.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,MAAc,EACd,MAAc,EACd,YAAoB;IAEpB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,WAAW,GAAG,CAAC,CAAC,gBAAgB,EAAE,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IAC7E,IAAI,CAAC,WAAW,EAAE;QAChB,WAAW,GAAG,CAAC,CAAC,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;KACzD;IAED,IAAI,OAAO,GAAG,CAAC,CAAC,8BAA8B,CAAC,CAAC,KAAK,EAAE,CAAC;IACxD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,GAAG,CAAC,CAAC,8BAA8B,CAAC,CAAC;KAC7C;IAED,+EAA+E;IAC/E,IAAI,WAAW,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IAEvC,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAC7C,CAAC,EACD,OAAO,EACP,MAAM,EACN,YAAY,CACb,CAAC;IAEF,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACnC,IAAI,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,2DAA2D;IAC3D,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE9C,qDAAqD;IACrD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAE3C,6BAA6B;IAC7B,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAEtD,iCAAiC;IACjC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE/C,gEAAgE;IAChE,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;IAEjE,QAAQ,GAAG,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEhE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import cheerio from "cheerio";
|
|
2
|
+
import { scrapeReadMePage } from "./scrapeReadMePage.js";
|
|
3
|
+
import { scrapeGettingFileNameFromUrl } from "../scrapeGettingFileNameFromUrl.js";
|
|
4
|
+
import getLinksRecursively from "./getLinksRecursively.js";
|
|
5
|
+
export async function scrapeReadMeSection(html, origin, cliDir, overwrite) {
|
|
6
|
+
const $ = cheerio.load(html);
|
|
7
|
+
// Get all the navigation sections, but only from the first
|
|
8
|
+
// sidebar found. There are multiple in the HTML for mobile
|
|
9
|
+
// responsiveness but they all have the same links.
|
|
10
|
+
const navigationSections = $(".rm-Sidebar")
|
|
11
|
+
.first()
|
|
12
|
+
.find(".rm-Sidebar-section");
|
|
13
|
+
const groupsConfig = navigationSections
|
|
14
|
+
.map((i, s) => {
|
|
15
|
+
const section = $(s);
|
|
16
|
+
const sectionTitle = section.find("h3").first().text();
|
|
17
|
+
// Get all links, then use filter to remove duplicates.
|
|
18
|
+
// There are duplicates because of nested navigation, eg:
|
|
19
|
+
// subgroupTitle -> /first-page
|
|
20
|
+
// -- First Page -> /first-page ** DUPLICATE **
|
|
21
|
+
// -- Second Page -> /second-page
|
|
22
|
+
const linkSections = section.find(".rm-Sidebar-list").first().children();
|
|
23
|
+
const pages = getLinksRecursively(linkSections, $).filter((value, index, self) => self.indexOf(value) === index);
|
|
24
|
+
// Follows the same structure as mint.json
|
|
25
|
+
return {
|
|
26
|
+
group: sectionTitle,
|
|
27
|
+
pages: pages,
|
|
28
|
+
};
|
|
29
|
+
})
|
|
30
|
+
.toArray();
|
|
31
|
+
return await Promise.all(groupsConfig.map(async (navEntry) => {
|
|
32
|
+
return await scrapeGettingFileNameFromUrl(
|
|
33
|
+
// ReadMe requires a directory on all sections wheras we use root.
|
|
34
|
+
// /docs is their default directory so we remove it
|
|
35
|
+
navEntry, cliDir, origin, overwrite, scrapeReadMePage, false, "/docs");
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=scrapeReadMeSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrapeReadMeSection.js","sourceRoot":"","sources":["../../../src/scraping/site-scrapers/scrapeReadMeSection.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAG3D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAY,EACZ,MAAc,EACd,MAAc,EACd,SAAkB;IAElB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7B,2DAA2D;IAC3D,2DAA2D;IAC3D,mDAAmD;IACnD,MAAM,kBAAkB,GAAG,CAAC,CAAC,aAAa,CAAC;SACxC,KAAK,EAAE;SACP,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAE/B,MAAM,YAAY,GAAG,kBAAkB;SACpC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAEvD,uDAAuD;QACvD,yDAAyD;QACzD,+BAA+B;QAC/B,iDAAiD;QACjD,iCAAiC;QACjC,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC;QACzE,MAAM,KAAK,GAAG,mBAAmB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,MAAM,CACvD,CAAC,KAAa,EAAE,KAAa,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,CACtE,CAAC;QAEF,0CAA0C;QAC1C,OAAO;YACL,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC,CAAC;SACD,OAAO,EAAE,CAAC;IAEb,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,QAAyB,EAAE,EAAE;QACnD,OAAO,MAAM,4BAA4B;QACvC,kEAAkE;QAClE,mDAAmD;QACnD,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,OAAO,CACR,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/bin/util.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "fs";
|
|
2
|
-
import
|
|
2
|
+
import Ora from "ora";
|
|
3
3
|
import path from "path";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { Page } from "./init-command/templates.js";
|
|
5
|
+
import stopIfInvalidLink from "./validation/stopIfInvalidLink.js";
|
|
6
|
+
export function getOrigin(url) {
|
|
6
7
|
// eg. https://google.com -> https://google.com
|
|
7
8
|
// https://google.com/page -> https://google.com
|
|
8
|
-
return url
|
|
9
|
+
return new URL(url).origin;
|
|
9
10
|
}
|
|
10
11
|
export function objToReadableString(objs) {
|
|
11
12
|
// Two spaces as indentation
|
|
@@ -26,12 +27,50 @@ export const addMdx = (fileName) => {
|
|
|
26
27
|
}
|
|
27
28
|
return fileName + ".mdx";
|
|
28
29
|
};
|
|
29
|
-
export const createPage = (title, description, markdown, rootDir = "", fileName) => {
|
|
30
|
+
export const createPage = (title, description, markdown, overwrite = false, rootDir = "", fileName) => {
|
|
31
|
+
const writePath = path.join(rootDir, addMdx(fileName || toFilename(title)));
|
|
30
32
|
// Create the folders needed if they're missing
|
|
31
33
|
mkdirSync(rootDir, { recursive: true });
|
|
32
34
|
// Write the page to memory
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
if (overwrite) {
|
|
36
|
+
writeFileSync(writePath, Page(title, description, markdown));
|
|
37
|
+
console.log("✏️ - " + writePath);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
try {
|
|
41
|
+
writeFileSync(writePath, Page(title, description, markdown), {
|
|
42
|
+
flag: "wx",
|
|
43
|
+
});
|
|
44
|
+
console.log("✏️ - " + writePath);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
// We do a try-catch instead of an if-statement to avoid a race condition
|
|
48
|
+
// of the file being created after we started writing.
|
|
49
|
+
if (e.code === "EEXIST") {
|
|
50
|
+
console.log(`❌ Skipping existing file ${writePath}`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.error(e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
export function getHrefFromArgs(argv) {
|
|
59
|
+
const href = argv.url;
|
|
60
|
+
stopIfInvalidLink(href);
|
|
61
|
+
return href;
|
|
62
|
+
}
|
|
63
|
+
export const buildLogger = (startText = "") => {
|
|
64
|
+
const logger = Ora().start(startText);
|
|
65
|
+
return logger;
|
|
66
|
+
};
|
|
67
|
+
export const getFileExtension = (filename) => {
|
|
68
|
+
return (filename.substring(filename.lastIndexOf(".") + 1, filename.length) ||
|
|
69
|
+
filename);
|
|
70
|
+
};
|
|
71
|
+
export const fileBelongsInPagesFolder = (filename) => {
|
|
72
|
+
const extension = getFileExtension(filename);
|
|
73
|
+
return (extension &&
|
|
74
|
+
(extension === "mdx" || extension === "md" || extension === "tsx"));
|
|
36
75
|
};
|
|
37
76
|
//# sourceMappingURL=util.js.map
|
package/bin/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidLink.js","sourceRoot":"","sources":["../../src/validation/isValidLink.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAY;IAC9C,uEAAuE;IACvE,IAAI;QACF,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import isValidLink from "./isValidLink.js";
|
|
2
|
+
export default function stopIfInvalidLink(href) {
|
|
3
|
+
if (!isValidLink(href)) {
|
|
4
|
+
console.log("Invalid link: " + href);
|
|
5
|
+
console.log("Make sure the link starts with http:// or https://");
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=stopIfInvalidLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stopIfInvalidLink.js","sourceRoot":"","sources":["../../src/validation/stopIfInvalidLink.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,IAAY;IACpD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;QACtB,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mintlify",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Mintlify CLI",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.16"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "tsc"
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"local": "npm uninstall -g mintlify && npm i -g ."
|
|
10
11
|
},
|
|
11
12
|
"author": "Mintlify, Inc.",
|
|
12
13
|
"license": "ISC",
|
|
@@ -16,15 +17,31 @@
|
|
|
16
17
|
},
|
|
17
18
|
"type": "module",
|
|
18
19
|
"dependencies": {
|
|
20
|
+
"@apidevtools/swagger-parser": "^10.1.0",
|
|
19
21
|
"axios": "^0.27.2",
|
|
22
|
+
"chalk": "^5.1.0",
|
|
20
23
|
"cheerio": "^0.22.0",
|
|
24
|
+
"chokidar": "^3.5.3",
|
|
25
|
+
"favicons": "^7.0.1",
|
|
26
|
+
"fs-extra": "^10.1.0",
|
|
27
|
+
"gray-matter": "^4.0.3",
|
|
21
28
|
"inquirer": "^9.1.0",
|
|
29
|
+
"is-internet-available": "^3.1.0",
|
|
30
|
+
"minimist-lite": "^2.2.1",
|
|
22
31
|
"node-html-markdown": "^1.2.0",
|
|
23
|
-
"
|
|
32
|
+
"open": "^8.4.0",
|
|
33
|
+
"openapi-types": "^12.0.2",
|
|
34
|
+
"ora": "^6.1.2",
|
|
35
|
+
"puppeteer": "^17.1.3",
|
|
36
|
+
"shelljs": "^0.8.5",
|
|
37
|
+
"yargs": "^17.6.0"
|
|
24
38
|
},
|
|
25
39
|
"devDependencies": {
|
|
40
|
+
"@types/fs-extra": "^9.0.13",
|
|
26
41
|
"@types/inquirer": "^9.0.1",
|
|
27
42
|
"@types/node": "^18.7.13",
|
|
43
|
+
"@types/shelljs": "^0.8.11",
|
|
44
|
+
"@types/yargs": "^17.0.13",
|
|
28
45
|
"typescript": "^4.8.2"
|
|
29
46
|
}
|
|
30
47
|
}
|
package/src/browser.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { launch } from "puppeteer";
|
|
2
|
+
|
|
3
|
+
export async function startBrowser() {
|
|
4
|
+
try {
|
|
5
|
+
return await launch({
|
|
6
|
+
headless: true,
|
|
7
|
+
ignoreHTTPSErrors: true,
|
|
8
|
+
});
|
|
9
|
+
} catch (err) {
|
|
10
|
+
console.log("Could not create a browser instance: ", err);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function getHtmlWithPuppeteer(href: string) {
|
|
16
|
+
const browser = await startBrowser();
|
|
17
|
+
const page = await browser.newPage();
|
|
18
|
+
await page.goto(href, {
|
|
19
|
+
waitUntil: "networkidle2",
|
|
20
|
+
});
|
|
21
|
+
const html = await page.content();
|
|
22
|
+
browser.close();
|
|
23
|
+
return html;
|
|
24
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import * as url from "url";
|
|
3
|
+
|
|
4
|
+
// package installation location
|
|
5
|
+
export const INSTALL_PATH = url.fileURLToPath(new URL(".", import.meta.url));
|
|
6
|
+
|
|
7
|
+
// command execution location
|
|
8
|
+
export const CMD_EXEC_PATH = process.cwd();
|
|
9
|
+
|
|
10
|
+
export const CLIENT_PATH = path.join(INSTALL_PATH, "mint", "client");
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, createWriteStream } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
export default async function downloadImage(
|
|
6
|
+
imageSrc: string,
|
|
7
|
+
writePath: string
|
|
8
|
+
) {
|
|
9
|
+
// Avoid unnecessary downloads
|
|
10
|
+
if (existsSync(writePath)) {
|
|
11
|
+
return Promise.reject({
|
|
12
|
+
code: "EEXIST",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Create the folders needed if they're missing
|
|
17
|
+
mkdirSync(path.dirname(writePath), { recursive: true });
|
|
18
|
+
|
|
19
|
+
const writer = createWriteStream(writePath);
|
|
20
|
+
|
|
21
|
+
const response = await axios.default.get(imageSrc, {
|
|
22
|
+
responseType: "stream",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// wx prevents overwriting an image with the exact same name
|
|
26
|
+
// being created in the time we were downloading
|
|
27
|
+
response.data.pipe(writer, {
|
|
28
|
+
flag: "wx",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
writer.on("finish", resolve);
|
|
33
|
+
writer.on("error", reject);
|
|
34
|
+
});
|
|
35
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,125 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import yargs from "yargs";
|
|
4
|
+
import { hideBin } from "yargs/helpers";
|
|
5
|
+
import initCommand from "./init-command/index.js";
|
|
6
|
+
import generatePageTemplate from "./pageTemplate.js";
|
|
7
|
+
import {
|
|
8
|
+
scrapePageAutomatically,
|
|
9
|
+
scrapePageWrapper,
|
|
10
|
+
} from "./scraping/scrapePageCommands.js";
|
|
11
|
+
import { scrapeDocusaurusPage } from "./scraping/site-scrapers/scrapeDocusaurusPage.js";
|
|
12
|
+
import { scrapeGitBookPage } from "./scraping/site-scrapers/scrapeGitBookPage.js";
|
|
13
|
+
import { scrapeReadMePage } from "./scraping/site-scrapers/scrapeReadMePage.js";
|
|
14
|
+
import {
|
|
15
|
+
scrapeSectionAutomatically,
|
|
16
|
+
scrapeSectionAxiosWrapper,
|
|
17
|
+
scrapeGitbookSectionCommand,
|
|
18
|
+
} from "./scraping/scrapeSectionCommands.js";
|
|
19
|
+
import { scrapeDocusaurusSection } from "./scraping/site-scrapers/scrapeDocusaurusSection.js";
|
|
20
|
+
import { scrapeReadMeSection } from "./scraping/site-scrapers/scrapeReadMeSection.js";
|
|
21
|
+
import dev from "./local-preview/index.js";
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
// TODO - add descriptions to the command options https://github.com/yargs/yargs/blob/HEAD/docs/api.md#commandmodule
|
|
24
|
+
yargs(hideBin(process.argv))
|
|
25
|
+
.command(
|
|
26
|
+
"dev",
|
|
27
|
+
"Runs Mintlify locally (Must run in directory with mint.json)",
|
|
28
|
+
() => {},
|
|
29
|
+
async () => {
|
|
30
|
+
await dev();
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
.command(
|
|
34
|
+
"init",
|
|
35
|
+
"Generate a mintlify template",
|
|
36
|
+
() => {},
|
|
37
|
+
() => {
|
|
38
|
+
initCommand();
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
.command(
|
|
42
|
+
"page",
|
|
43
|
+
"Generate a new page",
|
|
44
|
+
() => {},
|
|
45
|
+
() => {
|
|
46
|
+
generatePageTemplate();
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
.command(
|
|
50
|
+
"scrape-page [url]",
|
|
51
|
+
"Scrapes a page",
|
|
52
|
+
() => {},
|
|
53
|
+
async (argv) => {
|
|
54
|
+
await scrapePageAutomatically(argv);
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
.command(
|
|
58
|
+
"scrape-docusaurus-page [url]",
|
|
59
|
+
"Scrapes a Docusaurus page",
|
|
60
|
+
() => {},
|
|
61
|
+
async (argv) => {
|
|
62
|
+
await scrapePageWrapper(argv, scrapeDocusaurusPage);
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
.command(
|
|
66
|
+
"scrape-gitbook-page [url]",
|
|
67
|
+
"Scrapes a GitBook page",
|
|
68
|
+
() => {},
|
|
69
|
+
async (argv) => {
|
|
70
|
+
await scrapePageWrapper(argv, scrapeGitBookPage);
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
.command(
|
|
74
|
+
"scrape-readme-page [url]",
|
|
75
|
+
"Scrapes a ReadMe page",
|
|
76
|
+
() => {},
|
|
77
|
+
async (argv) => {
|
|
78
|
+
await scrapePageWrapper(argv, scrapeReadMePage);
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
.command(
|
|
82
|
+
"scrape-section [url]",
|
|
83
|
+
"Scrapes the docs in the section",
|
|
84
|
+
() => {},
|
|
85
|
+
async (argv) => {
|
|
86
|
+
await scrapeSectionAutomatically(argv);
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
.command(
|
|
90
|
+
"scrape-docusaurus-section [url]",
|
|
91
|
+
"Scrapes the Docusaurus section",
|
|
92
|
+
() => {},
|
|
93
|
+
async (argv) => {
|
|
94
|
+
await scrapeSectionAxiosWrapper(argv, scrapeDocusaurusSection);
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
.command(
|
|
98
|
+
"scrape-gitbook-section [url]",
|
|
99
|
+
"Scrapes the Gitbook section",
|
|
100
|
+
() => {},
|
|
101
|
+
async (argv) => {
|
|
102
|
+
await scrapeGitbookSectionCommand(argv);
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
.command(
|
|
106
|
+
"scrape-readme-section [url]",
|
|
107
|
+
"Scrapes the ReadMe section",
|
|
108
|
+
() => {},
|
|
109
|
+
async (argv) => {
|
|
110
|
+
await scrapeSectionAxiosWrapper(argv, scrapeReadMeSection);
|
|
111
|
+
}
|
|
112
|
+
)
|
|
12
113
|
|
|
13
|
-
|
|
14
|
-
console.error(
|
|
15
|
-
`No command specified. Here are is the list that you can use:\ninit: initialize a Mintlify documentation instance`
|
|
16
|
-
);
|
|
17
|
-
process.exit(1); //an error occurred
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const command = args[0];
|
|
21
|
-
|
|
22
|
-
if (command === "init") {
|
|
23
|
-
inquirer
|
|
24
|
-
.prompt([
|
|
25
|
-
{
|
|
26
|
-
type: "input",
|
|
27
|
-
name: "name",
|
|
28
|
-
message: "What is the name of the organization?",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: "input",
|
|
32
|
-
name: "color",
|
|
33
|
-
message: "What is the primary color of the brand?",
|
|
34
|
-
default: "#3b83f4",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: "input",
|
|
38
|
-
name: "ctaName",
|
|
39
|
-
message: "What is the name of the call to action button?",
|
|
40
|
-
default: "Get Started",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: "input",
|
|
44
|
-
name: "ctaUrl",
|
|
45
|
-
message: "What is the URL destination of the call to action button?",
|
|
46
|
-
default: "/",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
type: "input",
|
|
50
|
-
name: "title",
|
|
51
|
-
message: "What is the title of the first page?",
|
|
52
|
-
default: "Introduction",
|
|
53
|
-
},
|
|
54
|
-
])
|
|
55
|
-
.then((answers) => {
|
|
56
|
-
const { name, color, ctaName, ctaUrl, title } = answers;
|
|
57
|
-
writeFileSync(
|
|
58
|
-
"mint.config.json",
|
|
59
|
-
JSON.stringify(
|
|
60
|
-
MintConfig(name, color, ctaName, ctaUrl, toFilename(title)),
|
|
61
|
-
null,
|
|
62
|
-
"\t"
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
createPage(title);
|
|
66
|
-
console.log("🌱 Created initial files for Mintlify docs");
|
|
67
|
-
process.exit(1);
|
|
68
|
-
})
|
|
69
|
-
.catch((error) => {
|
|
70
|
-
console.error(error);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (command === "page") {
|
|
76
|
-
inquirer
|
|
77
|
-
.prompt([
|
|
78
|
-
{
|
|
79
|
-
type: "input",
|
|
80
|
-
name: "title",
|
|
81
|
-
message: "What is the title of the new page?",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
type: "input",
|
|
85
|
-
name: "description",
|
|
86
|
-
message: "What is the description?",
|
|
87
|
-
default: "",
|
|
88
|
-
},
|
|
89
|
-
])
|
|
90
|
-
.then((answers) => {
|
|
91
|
-
const { title, description } = answers;
|
|
92
|
-
|
|
93
|
-
createPage(title, description);
|
|
94
|
-
console.log("🌱 Created initial files for Mintlify docs");
|
|
95
|
-
process.exit(1);
|
|
96
|
-
})
|
|
97
|
-
.catch((error) => {
|
|
98
|
-
console.error(error);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (command === "scrape-gitbook-page") {
|
|
104
|
-
const url = args[1];
|
|
105
|
-
const { title, description, markdown } = await scrapeGitBookPage(url);
|
|
106
|
-
createPage(title, description, markdown, process.cwd());
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (command === "scrape-readme-page") {
|
|
111
|
-
const url = args[1];
|
|
112
|
-
const { title, description, markdown } = await scrapeReadMePage(url);
|
|
113
|
-
createPage(title, description, markdown, process.cwd());
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (command === "scrape-readme-section") {
|
|
118
|
-
const url = args[1];
|
|
119
|
-
console.log("Started scraping...");
|
|
120
|
-
const groupsConfig = await scrapeReadMe(url, process.cwd());
|
|
121
|
-
console.log("Finished scraping.");
|
|
122
|
-
console.log("Add the following to your navigation in mint.config.js:");
|
|
123
|
-
console.log(objToReadableString(groupsConfig));
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
114
|
+
.parse();
|