mintlify 1.0.7 → 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 +21 -5
- 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/index.js +45 -224
- 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/getSitemapLinks.js +2 -0
- package/bin/scraping/getSitemapLinks.js.map +1 -1
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +43 -0
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +1 -0
- package/bin/scraping/scrapeGettingFileNameFromUrl.js +12 -41
- package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +1 -1
- package/bin/scraping/scrapePageCommands.js +48 -0
- package/bin/scraping/scrapePageCommands.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/scrapeDocusaurusSection.js +1 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +25 -48
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeReadMePage.js +2 -1
- package/bin/scraping/site-scrapers/scrapeReadMePage.js.map +1 -1
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js +10 -20
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +1 -1
- package/bin/util.js +21 -1
- 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 +20 -4
- package/src/constants.ts +10 -0
- package/src/index.ts +110 -272
- 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/getSitemapLinks.ts +2 -0
- package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +81 -0
- package/src/scraping/scrapeGettingFileNameFromUrl.ts +27 -58
- package/src/scraping/scrapePageCommands.ts +52 -0
- package/src/scraping/scrapeSectionCommands.ts +110 -0
- package/src/scraping/site-scrapers/getLinksRecursively.ts +40 -0
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +1 -1
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +31 -70
- package/src/scraping/site-scrapers/scrapeReadMePage.ts +3 -1
- package/src/scraping/site-scrapers/scrapeReadMeSection.ts +21 -38
- package/src/util.ts +29 -1
- package/src/validation/isValidLink.ts +9 -0
- package/src/validation/stopIfInvalidLink.ts +9 -0
|
@@ -1 +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;
|
|
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,6 +1,8 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "fs";
|
|
2
|
+
import Ora from "ora";
|
|
2
3
|
import path from "path";
|
|
3
|
-
import { Page } from "./templates.js";
|
|
4
|
+
import { Page } from "./init-command/templates.js";
|
|
5
|
+
import stopIfInvalidLink from "./validation/stopIfInvalidLink.js";
|
|
4
6
|
export function getOrigin(url) {
|
|
5
7
|
// eg. https://google.com -> https://google.com
|
|
6
8
|
// https://google.com/page -> https://google.com
|
|
@@ -53,4 +55,22 @@ export const createPage = (title, description, markdown, overwrite = false, root
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
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"));
|
|
75
|
+
};
|
|
56
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,IAAI,MAAM,MAAM,CAAC;AACxB,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,16 +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",
|
|
22
30
|
"minimist-lite": "^2.2.1",
|
|
23
31
|
"node-html-markdown": "^1.2.0",
|
|
24
|
-
"
|
|
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"
|
|
25
38
|
},
|
|
26
39
|
"devDependencies": {
|
|
40
|
+
"@types/fs-extra": "^9.0.13",
|
|
27
41
|
"@types/inquirer": "^9.0.1",
|
|
28
42
|
"@types/node": "^18.7.13",
|
|
43
|
+
"@types/shelljs": "^0.8.11",
|
|
44
|
+
"@types/yargs": "^17.0.13",
|
|
29
45
|
"typescript": "^4.8.2"
|
|
30
46
|
}
|
|
31
47
|
}
|
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");
|
package/src/index.ts
CHANGED
|
@@ -1,276 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
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
11
|
import { scrapeDocusaurusPage } from "./scraping/site-scrapers/scrapeDocusaurusPage.js";
|
|
12
|
-
import { scrapeDocusaurusSection } from "./scraping/site-scrapers/scrapeDocusaurusSection.js";
|
|
13
12
|
import { scrapeGitBookPage } from "./scraping/site-scrapers/scrapeGitBookPage.js";
|
|
14
|
-
import { scrapeGitBookSection } from "./scraping/site-scrapers/scrapeGitBookSection.js";
|
|
15
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";
|
|
16
20
|
import { scrapeReadMeSection } from "./scraping/site-scrapers/scrapeReadMeSection.js";
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.catch((error) => {
|
|
112
|
-
console.error(error);
|
|
113
|
-
process.exit(1);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function validateFramework(framework) {
|
|
118
|
-
if (!framework) {
|
|
119
|
-
console.log(
|
|
120
|
-
"Could not detect the framework automatically. Please use one of:"
|
|
121
|
-
);
|
|
122
|
-
console.log("scrape-page-docusaurus");
|
|
123
|
-
console.log("scrape-page-gitbook");
|
|
124
|
-
console.log("scrape-page-readme");
|
|
125
|
-
return process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function scrapePageAutomatically() {
|
|
130
|
-
const href = argv._[1];
|
|
131
|
-
const res = await axios.default.get(href);
|
|
132
|
-
const html = res.data;
|
|
133
|
-
const framework = detectFramework(html);
|
|
134
|
-
|
|
135
|
-
validateFramework(framework);
|
|
136
|
-
|
|
137
|
-
console.log("Detected framework: " + framework);
|
|
138
|
-
|
|
139
|
-
if (framework === Frameworks.DOCUSAURUS) {
|
|
140
|
-
await scrapePageWrapper(scrapeDocusaurusPage);
|
|
141
|
-
} else if (framework === Frameworks.GITBOOK) {
|
|
142
|
-
await scrapePageWrapper(scrapeGitBookPage, true);
|
|
143
|
-
} else if (framework === Frameworks.README) {
|
|
144
|
-
await scrapePageWrapper(scrapeReadMePage);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function scrapePageWrapper(scrapeFunc, puppeteer = false) {
|
|
149
|
-
const href = argv._[1];
|
|
150
|
-
let html;
|
|
151
|
-
if (puppeteer) {
|
|
152
|
-
html = await getHtmlWithPuppeteer(href);
|
|
153
|
-
} else {
|
|
154
|
-
const res = await axios.default.get(href);
|
|
155
|
-
html = res.data;
|
|
156
|
-
}
|
|
157
|
-
await scrapePage(scrapeFunc, href, html, argv.overwrite);
|
|
158
|
-
process.exit(1);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (command === "scrape-page") {
|
|
162
|
-
await scrapePageAutomatically();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (command === "scrape-docusaurus-page") {
|
|
166
|
-
await scrapePageWrapper(scrapeDocusaurusPage);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (command === "scrape-gitbook-page") {
|
|
170
|
-
await scrapePageWrapper(scrapeGitBookPage, true);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (command === "scrape-readme-page") {
|
|
174
|
-
await scrapePageWrapper(scrapeReadMePage);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async function scrapeSectionAutomatically() {
|
|
178
|
-
const href = argv._[1];
|
|
179
|
-
const res = await axios.default.get(href);
|
|
180
|
-
const html = res.data;
|
|
181
|
-
const framework = detectFramework(html);
|
|
182
|
-
|
|
183
|
-
validateFramework(framework);
|
|
184
|
-
|
|
185
|
-
console.log("Detected framework: " + framework);
|
|
186
|
-
|
|
187
|
-
if (framework === Frameworks.DOCUSAURUS) {
|
|
188
|
-
await scrapeSectionAxiosWrapper(scrapeDocusaurusSection);
|
|
189
|
-
} else if (framework === Frameworks.GITBOOK) {
|
|
190
|
-
await scrapeSectionGitBookWrapper(scrapeGitBookSection);
|
|
191
|
-
} else if (framework === Frameworks.README) {
|
|
192
|
-
await scrapeSectionAxiosWrapper(scrapeReadMeSection);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async function scrapeSectionAxiosWrapper(scrapeFunc: any) {
|
|
197
|
-
const href = argv._[1];
|
|
198
|
-
const res = await axios.default.get(href);
|
|
199
|
-
const html = res.data;
|
|
200
|
-
await scrapeSection(scrapeFunc, html, getOrigin(href), argv.overwrite);
|
|
201
|
-
process.exit(1);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
async function scrapeSectionGitBookWrapper(scrapeFunc: any) {
|
|
205
|
-
const href = argv._[1];
|
|
206
|
-
|
|
207
|
-
const browser = await startBrowser();
|
|
208
|
-
const page = await browser.newPage();
|
|
209
|
-
await page.goto(href, {
|
|
210
|
-
waitUntil: "networkidle2",
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
let prevEncountered = [];
|
|
214
|
-
let encounteredHref = ["fake"];
|
|
215
|
-
|
|
216
|
-
// Loop until we've encountered every link
|
|
217
|
-
while (!encounteredHref.every((href) => prevEncountered.includes(href))) {
|
|
218
|
-
prevEncountered = encounteredHref;
|
|
219
|
-
encounteredHref = await page.evaluate(
|
|
220
|
-
(encounteredHref) => {
|
|
221
|
-
const icons = Array.from(
|
|
222
|
-
document.querySelectorAll('path[d="M9 18l6-6-6-6"]')
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
const linksFound = [];
|
|
226
|
-
icons.forEach(async (icon: HTMLElement) => {
|
|
227
|
-
const toClick = icon.parentElement.parentElement;
|
|
228
|
-
const link = toClick.parentElement.parentElement;
|
|
229
|
-
|
|
230
|
-
// Skip icons not in the side navigation
|
|
231
|
-
if (!link.hasAttribute("href")) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const href = link.getAttribute("href");
|
|
236
|
-
|
|
237
|
-
// Should never occur but we keep it as a fail-safe
|
|
238
|
-
if (href.startsWith("https://") || href.startsWith("http://")) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Click any links we haven't seen before
|
|
243
|
-
if (!encounteredHref.includes(href)) {
|
|
244
|
-
toClick.click();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
linksFound.push(href);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
return linksFound;
|
|
251
|
-
},
|
|
252
|
-
encounteredHref // Need to pass array into the browser
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const html = await page.content();
|
|
257
|
-
browser.close();
|
|
258
|
-
await scrapeSection(scrapeFunc, html, getOrigin(href), argv.overwrite);
|
|
259
|
-
process.exit(1);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (command === "scrape-section") {
|
|
263
|
-
await scrapeSectionAutomatically();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (command === "scrape-docusaurus-section") {
|
|
267
|
-
await scrapeSectionAxiosWrapper(scrapeDocusaurusSection);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (command === "scrape-gitbook-section") {
|
|
271
|
-
await scrapeSectionGitBookWrapper(scrapeGitBookSection);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (command === "scrape-readme-section") {
|
|
275
|
-
await scrapeSectionAxiosWrapper(scrapeReadMeSection);
|
|
276
|
-
}
|
|
21
|
+
import dev from "./local-preview/index.js";
|
|
22
|
+
|
|
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
|
+
)
|
|
113
|
+
|
|
114
|
+
.parse();
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import { writeFileSync } from "fs";
|
|
3
|
+
import { MintConfig } from "./templates.js";
|
|
4
|
+
import { createPage, toFilename } from "../util.js";
|
|
5
|
+
|
|
6
|
+
const initCommand = () => {
|
|
7
|
+
inquirer
|
|
8
|
+
.prompt([
|
|
9
|
+
{
|
|
10
|
+
type: "input",
|
|
11
|
+
name: "name",
|
|
12
|
+
message: "What is the name of the organization?",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "input",
|
|
16
|
+
name: "color",
|
|
17
|
+
message: "What is the primary color of the brand?",
|
|
18
|
+
default: "#3b83f4",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "input",
|
|
22
|
+
name: "ctaName",
|
|
23
|
+
message: "What is the name of the call to action button?",
|
|
24
|
+
default: "Get Started",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "input",
|
|
28
|
+
name: "ctaUrl",
|
|
29
|
+
message: "What is the URL destination of the call to action button?",
|
|
30
|
+
default: "/",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "input",
|
|
34
|
+
name: "title",
|
|
35
|
+
message: "What is the title of the first page?",
|
|
36
|
+
default: "Introduction",
|
|
37
|
+
},
|
|
38
|
+
])
|
|
39
|
+
.then((answers) => {
|
|
40
|
+
const { name, color, ctaName, ctaUrl, title } = answers;
|
|
41
|
+
writeFileSync(
|
|
42
|
+
"mint.json",
|
|
43
|
+
JSON.stringify(
|
|
44
|
+
MintConfig(name, color, ctaName, ctaUrl, toFilename(title)),
|
|
45
|
+
null,
|
|
46
|
+
"\t"
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
createPage(title);
|
|
50
|
+
console.log("🌱 Created initial files for Mintlify docs");
|
|
51
|
+
process.exit(0);
|
|
52
|
+
})
|
|
53
|
+
.catch((error) => {
|
|
54
|
+
console.error(error);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default initCommand;
|
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { promises as _promises } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { CMD_EXEC_PATH } from "../constants.js";
|
|
5
|
+
import openApiCheck from "./openApiCheck.js";
|
|
6
|
+
import { getFileExtension } from "../util.js";
|
|
7
|
+
|
|
8
|
+
const { readdir } = _promises;
|
|
9
|
+
|
|
10
|
+
const getFileList = async (dirName: string, og = dirName) => {
|
|
11
|
+
let files = [];
|
|
12
|
+
const items = await readdir(dirName, { withFileTypes: true });
|
|
13
|
+
|
|
14
|
+
for (const item of items) {
|
|
15
|
+
if (item.isDirectory()) {
|
|
16
|
+
files = [...files, ...(await getFileList(`${dirName}/${item.name}`, og))];
|
|
17
|
+
} else {
|
|
18
|
+
const path = `${dirName}/${item.name}`;
|
|
19
|
+
const name = path.replace(og, "");
|
|
20
|
+
files.push({ path, isSymbolicLink: item.isSymbolicLink(), name });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return files;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const categorizeFiles = async (): Promise<{
|
|
28
|
+
markdownFiles: string[];
|
|
29
|
+
staticFiles: string[];
|
|
30
|
+
openApiBuffer: Buffer | undefined;
|
|
31
|
+
}> => {
|
|
32
|
+
const allFilesInCmdExecutionPath = await getFileList(CMD_EXEC_PATH);
|
|
33
|
+
const markdownFiles = [];
|
|
34
|
+
const staticFiles = [];
|
|
35
|
+
const promises = [];
|
|
36
|
+
let openApiBuffer = undefined;
|
|
37
|
+
allFilesInCmdExecutionPath.forEach((file) => {
|
|
38
|
+
promises.push(
|
|
39
|
+
(async () => {
|
|
40
|
+
const extension = getFileExtension(file.name);
|
|
41
|
+
let isOpenApi = false;
|
|
42
|
+
if (
|
|
43
|
+
extension &&
|
|
44
|
+
(extension === "mdx" || extension === "md" || extension === "tsx")
|
|
45
|
+
) {
|
|
46
|
+
markdownFiles.push(file.name);
|
|
47
|
+
} else if (
|
|
48
|
+
extension &&
|
|
49
|
+
(extension === "json" || extension === "yaml" || extension === "yml")
|
|
50
|
+
) {
|
|
51
|
+
const openApiInfo = await openApiCheck(
|
|
52
|
+
path.join(CMD_EXEC_PATH, file.name)
|
|
53
|
+
);
|
|
54
|
+
isOpenApi = openApiInfo.isOpenApi;
|
|
55
|
+
if (isOpenApi) {
|
|
56
|
+
openApiBuffer = openApiInfo.buffer;
|
|
57
|
+
}
|
|
58
|
+
} else if (
|
|
59
|
+
(!file.name.endsWith("mint.config.json") ||
|
|
60
|
+
!file.name.endsWith("mint.json")) &&
|
|
61
|
+
!isOpenApi
|
|
62
|
+
) {
|
|
63
|
+
// all other files
|
|
64
|
+
staticFiles.push(file.name);
|
|
65
|
+
}
|
|
66
|
+
})()
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
await Promise.all(promises);
|
|
70
|
+
|
|
71
|
+
return { markdownFiles, staticFiles, openApiBuffer };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default categorizeFiles;
|