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
package/bin/index.js
CHANGED
|
@@ -1,229 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { scrapePage } from "./scraping/scrapePage.js";
|
|
8
|
-
import { scrapeSection } from "./scraping/scrapeSection.js";
|
|
9
|
-
import { createPage, toFilename, getOrigin } from "./util.js";
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
import { hideBin } from "yargs/helpers";
|
|
4
|
+
import initCommand from "./init-command/index.js";
|
|
5
|
+
import generatePageTemplate from "./pageTemplate.js";
|
|
6
|
+
import { scrapePageAutomatically, scrapePageWrapper, } from "./scraping/scrapePageCommands.js";
|
|
10
7
|
import { scrapeDocusaurusPage } from "./scraping/site-scrapers/scrapeDocusaurusPage.js";
|
|
11
|
-
import { scrapeDocusaurusSection } from "./scraping/site-scrapers/scrapeDocusaurusSection.js";
|
|
12
8
|
import { scrapeGitBookPage } from "./scraping/site-scrapers/scrapeGitBookPage.js";
|
|
13
|
-
import { scrapeGitBookSection } from "./scraping/site-scrapers/scrapeGitBookSection.js";
|
|
14
9
|
import { scrapeReadMePage } from "./scraping/site-scrapers/scrapeReadMePage.js";
|
|
10
|
+
import { scrapeSectionAutomatically, scrapeSectionAxiosWrapper, scrapeGitbookSectionCommand, } from "./scraping/scrapeSectionCommands.js";
|
|
11
|
+
import { scrapeDocusaurusSection } from "./scraping/site-scrapers/scrapeDocusaurusSection.js";
|
|
15
12
|
import { scrapeReadMeSection } from "./scraping/site-scrapers/scrapeReadMeSection.js";
|
|
16
|
-
import
|
|
17
|
-
|
|
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
|
-
default: "/",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: "input",
|
|
57
|
-
name: "title",
|
|
58
|
-
message: "What is the title of the first page?",
|
|
59
|
-
default: "Introduction",
|
|
60
|
-
},
|
|
61
|
-
])
|
|
62
|
-
.then((answers) => {
|
|
63
|
-
const { name, color, ctaName, ctaUrl, title } = answers;
|
|
64
|
-
writeFileSync("mint.json", JSON.stringify(MintConfig(name, color, ctaName, ctaUrl, toFilename(title)), null, "\t"));
|
|
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
|
-
if (command === "page") {
|
|
75
|
-
inquirer
|
|
76
|
-
.prompt([
|
|
77
|
-
{
|
|
78
|
-
type: "input",
|
|
79
|
-
name: "title",
|
|
80
|
-
message: "What is the title of the new page?",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
type: "input",
|
|
84
|
-
name: "description",
|
|
85
|
-
message: "What is the description?",
|
|
86
|
-
default: "",
|
|
87
|
-
},
|
|
88
|
-
])
|
|
89
|
-
.then((answers) => {
|
|
90
|
-
const { title, description } = answers;
|
|
91
|
-
createPage(title, description);
|
|
92
|
-
console.log("🌱 Created initial files for Mintlify docs");
|
|
93
|
-
process.exit(1);
|
|
94
|
-
})
|
|
95
|
-
.catch((error) => {
|
|
96
|
-
console.error(error);
|
|
97
|
-
process.exit(1);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function validateFramework(framework) {
|
|
101
|
-
if (!framework) {
|
|
102
|
-
console.log("Could not detect the framework automatically. Please use one of:");
|
|
103
|
-
console.log("scrape-page-docusaurus");
|
|
104
|
-
console.log("scrape-page-gitbook");
|
|
105
|
-
console.log("scrape-page-readme");
|
|
106
|
-
return process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async function scrapePageAutomatically() {
|
|
110
|
-
const href = argv._[1];
|
|
111
|
-
const res = await axios.default.get(href);
|
|
112
|
-
const html = res.data;
|
|
113
|
-
const framework = detectFramework(html);
|
|
114
|
-
validateFramework(framework);
|
|
115
|
-
console.log("Detected framework: " + framework);
|
|
116
|
-
if (framework === Frameworks.DOCUSAURUS) {
|
|
117
|
-
await scrapePageWrapper(scrapeDocusaurusPage);
|
|
118
|
-
}
|
|
119
|
-
else if (framework === Frameworks.GITBOOK) {
|
|
120
|
-
await scrapePageWrapper(scrapeGitBookPage, true);
|
|
121
|
-
}
|
|
122
|
-
else if (framework === Frameworks.README) {
|
|
123
|
-
await scrapePageWrapper(scrapeReadMePage);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async function scrapePageWrapper(scrapeFunc, puppeteer = false) {
|
|
127
|
-
const href = argv._[1];
|
|
128
|
-
let html;
|
|
129
|
-
if (puppeteer) {
|
|
130
|
-
html = await getHtmlWithPuppeteer(href);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const res = await axios.default.get(href);
|
|
134
|
-
html = res.data;
|
|
135
|
-
}
|
|
136
|
-
await scrapePage(scrapeFunc, href, html, argv.overwrite);
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
if (command === "scrape-page") {
|
|
140
|
-
await scrapePageAutomatically();
|
|
141
|
-
}
|
|
142
|
-
if (command === "scrape-docusaurus-page") {
|
|
143
|
-
await scrapePageWrapper(scrapeDocusaurusPage);
|
|
144
|
-
}
|
|
145
|
-
if (command === "scrape-gitbook-page") {
|
|
146
|
-
await scrapePageWrapper(scrapeGitBookPage, true);
|
|
147
|
-
}
|
|
148
|
-
if (command === "scrape-readme-page") {
|
|
149
|
-
await scrapePageWrapper(scrapeReadMePage);
|
|
150
|
-
}
|
|
151
|
-
async function scrapeSectionAutomatically() {
|
|
152
|
-
const href = argv._[1];
|
|
153
|
-
const res = await axios.default.get(href);
|
|
154
|
-
const html = res.data;
|
|
155
|
-
const framework = detectFramework(html);
|
|
156
|
-
validateFramework(framework);
|
|
157
|
-
console.log("Detected framework: " + framework);
|
|
158
|
-
if (framework === Frameworks.DOCUSAURUS) {
|
|
159
|
-
await scrapeSectionAxiosWrapper(scrapeDocusaurusSection);
|
|
160
|
-
}
|
|
161
|
-
else if (framework === Frameworks.GITBOOK) {
|
|
162
|
-
await scrapeSectionGitBookWrapper(scrapeGitBookSection);
|
|
163
|
-
}
|
|
164
|
-
else if (framework === Frameworks.README) {
|
|
165
|
-
await scrapeSectionAxiosWrapper(scrapeReadMeSection);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async function scrapeSectionAxiosWrapper(scrapeFunc) {
|
|
169
|
-
const href = argv._[1];
|
|
170
|
-
const res = await axios.default.get(href);
|
|
171
|
-
const html = res.data;
|
|
172
|
-
await scrapeSection(scrapeFunc, html, getOrigin(href), argv.overwrite);
|
|
173
|
-
process.exit(1);
|
|
174
|
-
}
|
|
175
|
-
async function scrapeSectionGitBookWrapper(scrapeFunc) {
|
|
176
|
-
const href = argv._[1];
|
|
177
|
-
const browser = await startBrowser();
|
|
178
|
-
const page = await browser.newPage();
|
|
179
|
-
await page.goto(href, {
|
|
180
|
-
waitUntil: "networkidle2",
|
|
181
|
-
});
|
|
182
|
-
let prevEncountered = [];
|
|
183
|
-
let encounteredHref = ["fake"];
|
|
184
|
-
// Loop until we've encountered every link
|
|
185
|
-
while (!encounteredHref.every((href) => prevEncountered.includes(href))) {
|
|
186
|
-
prevEncountered = encounteredHref;
|
|
187
|
-
encounteredHref = await page.evaluate((encounteredHref) => {
|
|
188
|
-
const icons = Array.from(document.querySelectorAll('path[d="M9 18l6-6-6-6"]'));
|
|
189
|
-
const linksFound = [];
|
|
190
|
-
icons.forEach(async (icon) => {
|
|
191
|
-
const toClick = icon.parentElement.parentElement;
|
|
192
|
-
const link = toClick.parentElement.parentElement;
|
|
193
|
-
// Skip icons not in the side navigation
|
|
194
|
-
if (!link.hasAttribute("href")) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const href = link.getAttribute("href");
|
|
198
|
-
// Should never occur but we keep it as a fail-safe
|
|
199
|
-
if (href.startsWith("https://") || href.startsWith("http://")) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
// Click any links we haven't seen before
|
|
203
|
-
if (!encounteredHref.includes(href)) {
|
|
204
|
-
toClick.click();
|
|
205
|
-
}
|
|
206
|
-
linksFound.push(href);
|
|
207
|
-
});
|
|
208
|
-
return linksFound;
|
|
209
|
-
}, encounteredHref // Need to pass array into the browser
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
const html = await page.content();
|
|
213
|
-
browser.close();
|
|
214
|
-
await scrapeSection(scrapeFunc, html, getOrigin(href), argv.overwrite);
|
|
215
|
-
process.exit(1);
|
|
216
|
-
}
|
|
217
|
-
if (command === "scrape-section") {
|
|
218
|
-
await scrapeSectionAutomatically();
|
|
219
|
-
}
|
|
220
|
-
if (command === "scrape-docusaurus-section") {
|
|
221
|
-
await scrapeSectionAxiosWrapper(scrapeDocusaurusSection);
|
|
222
|
-
}
|
|
223
|
-
if (command === "scrape-gitbook-section") {
|
|
224
|
-
await scrapeSectionGitBookWrapper(scrapeGitBookSection);
|
|
225
|
-
}
|
|
226
|
-
if (command === "scrape-readme-section") {
|
|
227
|
-
await scrapeSectionAxiosWrapper(scrapeReadMeSection);
|
|
228
|
-
}
|
|
13
|
+
import dev from "./local-preview/index.js";
|
|
14
|
+
// TODO - add descriptions to the command options https://github.com/yargs/yargs/blob/HEAD/docs/api.md#commandmodule
|
|
15
|
+
yargs(hideBin(process.argv))
|
|
16
|
+
.command("dev", "Runs Mintlify locally (Must run in directory with mint.json)", () => { }, async () => {
|
|
17
|
+
await dev();
|
|
18
|
+
})
|
|
19
|
+
.command("init", "Generate a mintlify template", () => { }, () => {
|
|
20
|
+
initCommand();
|
|
21
|
+
})
|
|
22
|
+
.command("page", "Generate a new page", () => { }, () => {
|
|
23
|
+
generatePageTemplate();
|
|
24
|
+
})
|
|
25
|
+
.command("scrape-page [url]", "Scrapes a page", () => { }, async (argv) => {
|
|
26
|
+
await scrapePageAutomatically(argv);
|
|
27
|
+
})
|
|
28
|
+
.command("scrape-docusaurus-page [url]", "Scrapes a Docusaurus page", () => { }, async (argv) => {
|
|
29
|
+
await scrapePageWrapper(argv, scrapeDocusaurusPage);
|
|
30
|
+
})
|
|
31
|
+
.command("scrape-gitbook-page [url]", "Scrapes a GitBook page", () => { }, async (argv) => {
|
|
32
|
+
await scrapePageWrapper(argv, scrapeGitBookPage);
|
|
33
|
+
})
|
|
34
|
+
.command("scrape-readme-page [url]", "Scrapes a ReadMe page", () => { }, async (argv) => {
|
|
35
|
+
await scrapePageWrapper(argv, scrapeReadMePage);
|
|
36
|
+
})
|
|
37
|
+
.command("scrape-section [url]", "Scrapes the docs in the section", () => { }, async (argv) => {
|
|
38
|
+
await scrapeSectionAutomatically(argv);
|
|
39
|
+
})
|
|
40
|
+
.command("scrape-docusaurus-section [url]", "Scrapes the Docusaurus section", () => { }, async (argv) => {
|
|
41
|
+
await scrapeSectionAxiosWrapper(argv, scrapeDocusaurusSection);
|
|
42
|
+
})
|
|
43
|
+
.command("scrape-gitbook-section [url]", "Scrapes the Gitbook section", () => { }, async (argv) => {
|
|
44
|
+
await scrapeGitbookSectionCommand(argv);
|
|
45
|
+
})
|
|
46
|
+
.command("scrape-readme-section [url]", "Scrapes the ReadMe section", () => { }, async (argv) => {
|
|
47
|
+
await scrapeSectionAxiosWrapper(argv, scrapeReadMeSection);
|
|
48
|
+
})
|
|
49
|
+
.parse();
|
|
229
50
|
//# sourceMappingURL=index.js.map
|
package/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,oBAAoB,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,qDAAqD,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,OAAO,GAAG,MAAM,0BAA0B,CAAC;AAE3C,oHAAoH;AACpH,KAAK,CAAC,OAAO,CA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0BAA0B,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC,CACF;KACA,OAAO,CACN,iCAAiC,EACjC,gCAAgC,EAChC,GAAG,EAAE,GAAE,CAAC,EACR,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;AACjE,CAAC,CACF;KACA,OAAO,CACN,8BAA8B,EAC9B,6BAA6B,EAC7B,GAAG,EAAE,GAAE,CAAC,EACR,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,2BAA2B,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC,CACF;KACA,OAAO,CACN,6BAA6B,EAC7B,4BAA4B,EAC5B,GAAG,EAAE,GAAE,CAAC,EACR,KAAK,EAAE,IAAI,EAAE,EAAE;IACb,MAAM,yBAAyB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAC7D,CAAC,CACF;KAEA,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import { writeFileSync } from "fs";
|
|
3
|
+
import { MintConfig } from "./templates.js";
|
|
4
|
+
import { createPage, toFilename } from "../util.js";
|
|
5
|
+
const initCommand = () => {
|
|
6
|
+
inquirer
|
|
7
|
+
.prompt([
|
|
8
|
+
{
|
|
9
|
+
type: "input",
|
|
10
|
+
name: "name",
|
|
11
|
+
message: "What is the name of the organization?",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: "input",
|
|
15
|
+
name: "color",
|
|
16
|
+
message: "What is the primary color of the brand?",
|
|
17
|
+
default: "#3b83f4",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "input",
|
|
21
|
+
name: "ctaName",
|
|
22
|
+
message: "What is the name of the call to action button?",
|
|
23
|
+
default: "Get Started",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "input",
|
|
27
|
+
name: "ctaUrl",
|
|
28
|
+
message: "What is the URL destination of the call to action button?",
|
|
29
|
+
default: "/",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "input",
|
|
33
|
+
name: "title",
|
|
34
|
+
message: "What is the title of the first page?",
|
|
35
|
+
default: "Introduction",
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
.then((answers) => {
|
|
39
|
+
const { name, color, ctaName, ctaUrl, title } = answers;
|
|
40
|
+
writeFileSync("mint.json", JSON.stringify(MintConfig(name, color, ctaName, ctaUrl, toFilename(title)), null, "\t"));
|
|
41
|
+
createPage(title);
|
|
42
|
+
console.log("🌱 Created initial files for Mintlify docs");
|
|
43
|
+
process.exit(0);
|
|
44
|
+
})
|
|
45
|
+
.catch((error) => {
|
|
46
|
+
console.error(error);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export default initCommand;
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/init-command/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,QAAQ;SACL,MAAM,CAAC;QACN;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,uCAAuC;SACjD;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,yCAAyC;YAClD,OAAO,EAAE,SAAS;SACnB;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,gDAAgD;YACzD,OAAO,EAAE,aAAa;SACvB;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,2DAA2D;YACpE,OAAO,EAAE,GAAG;SACb;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,sCAAsC;YAC/C,OAAO,EAAE,cAAc;SACxB;KACF,CAAC;SACD,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAChB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QACxD,aAAa,CACX,WAAW,EACX,IAAI,CAAC,SAAS,CACZ,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAC3D,IAAI,EACJ,IAAI,CACL,CACF,CAAC;QACF,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const MintConfig = (name, color, ctaName, ctaUrl, filename) => {
|
|
2
|
+
return {
|
|
3
|
+
name,
|
|
4
|
+
logo: "",
|
|
5
|
+
favicon: "",
|
|
6
|
+
colors: {
|
|
7
|
+
primary: color,
|
|
8
|
+
},
|
|
9
|
+
topbarLinks: [],
|
|
10
|
+
topbarCtaButton: {
|
|
11
|
+
name: ctaName,
|
|
12
|
+
url: ctaUrl,
|
|
13
|
+
},
|
|
14
|
+
anchors: [],
|
|
15
|
+
navigation: [
|
|
16
|
+
{
|
|
17
|
+
group: "Home",
|
|
18
|
+
pages: [filename],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
// footerSocials: {}, // support object type for footer tyoes
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const Page = (title, description, markdown) => {
|
|
25
|
+
// If we are an empty String we want to add two quotes,
|
|
26
|
+
// if we added as we went we would detect the first quote
|
|
27
|
+
// as the closing quote.
|
|
28
|
+
const startsWithQuote = title.startsWith('"');
|
|
29
|
+
const endsWithQuote = title.startsWith('"');
|
|
30
|
+
if (!startsWithQuote) {
|
|
31
|
+
title = '"' + title;
|
|
32
|
+
}
|
|
33
|
+
if (!endsWithQuote) {
|
|
34
|
+
title = title + '"';
|
|
35
|
+
}
|
|
36
|
+
const optionalDescription = description
|
|
37
|
+
? `\ndescription: "${description}"`
|
|
38
|
+
: "";
|
|
39
|
+
return `---\ntitle: ${title}${optionalDescription}\n---\n\n${markdown}`;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/init-command/templates.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAY,EACZ,KAAa,EACb,OAAe,EACf,MAAc,EACd,QAAgB,EAChB,EAAE;IACF,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE,KAAK;SACf;QACD,WAAW,EAAE,EAAE;QACf,eAAe,EAAE;YACf,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,MAAM;SACZ;QACD,OAAO,EAAE,EAAE;QACX,UAAU,EAAE;YACV;gBACE,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,CAAC,QAAQ,CAAC;aAClB;SACF;QACD,6DAA6D;KAC9D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,KAAa,EACb,WAAoB,EACpB,QAAiB,EACjB,EAAE;IACF,uDAAuD;IACvD,yDAAyD;IACzD,wBAAwB;IACxB,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,eAAe,EAAE;QACpB,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;KACrB;IACD,IAAI,CAAC,aAAa,EAAE;QAClB,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;KACrB;IAED,MAAM,mBAAmB,GAAG,WAAW;QACrC,CAAC,CAAC,mBAAmB,WAAW,GAAG;QACnC,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,eAAe,KAAK,GAAG,mBAAmB,YAAY,QAAQ,EAAE,CAAC;AAC1E,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
let openApiBuffer = undefined;
|
|
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
|
+
openApiBuffer = openApiInfo.buffer;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if ((!file.name.endsWith("mint.config.json") ||
|
|
45
|
+
!file.name.endsWith("mint.json")) &&
|
|
46
|
+
!isOpenApi) {
|
|
47
|
+
// all other files
|
|
48
|
+
staticFiles.push(file.name);
|
|
49
|
+
}
|
|
50
|
+
})());
|
|
51
|
+
});
|
|
52
|
+
await Promise.all(promises);
|
|
53
|
+
return { markdownFiles, staticFiles, openApiBuffer };
|
|
54
|
+
};
|
|
55
|
+
export default categorizeFiles;
|
|
56
|
+
//# sourceMappingURL=categorizeFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categorizeFiles.js","sourceRoot":"","sources":["../../src/local-preview/categorizeFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,aAAa,E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2
|
+
const methodRegex = /^get|post|put|delete|patch/i;
|
|
3
|
+
const trimmed = api.trim();
|
|
4
|
+
const foundMethod = trimmed.match(methodRegex);
|
|
5
|
+
const endIndexOfMethod = foundMethod
|
|
6
|
+
? api.indexOf(foundMethod[0]) + foundMethod[0].length
|
|
7
|
+
: 0;
|
|
8
|
+
return {
|
|
9
|
+
method: foundMethod ? foundMethod[0].toUpperCase() : undefined,
|
|
10
|
+
endpoint: api.substring(endIndexOfMethod).trim(),
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const getOpenApiOperationMethodAndEndpoint = (openApiObj, openApiMetaField) => {
|
|
14
|
+
const { endpoint, method } = extractMethodAndEndpoint(openApiMetaField);
|
|
15
|
+
const path = (openApiObj === null || openApiObj === void 0 ? void 0 : openApiObj.paths) && openApiObj.paths[endpoint];
|
|
16
|
+
if (path == null) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
let operation;
|
|
20
|
+
if (method) {
|
|
21
|
+
operation = path[method.toLowerCase()];
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const firstOperationKey = Object.keys(path)[0];
|
|
25
|
+
operation = path[firstOperationKey];
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
operation,
|
|
29
|
+
method,
|
|
30
|
+
endpoint,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export const getOpenApiTitleAndDescription = (openApiObj, openApiMetaField) => {
|
|
34
|
+
if (openApiObj == null || !openApiMetaField || openApiMetaField == null) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const { operation } = getOpenApiOperationMethodAndEndpoint(openApiObj, openApiMetaField);
|
|
38
|
+
if (operation == null) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
title: operation.summary,
|
|
43
|
+
description: operation.description,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=getOpenApiContext.js.map
|
|
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