mintlify 2.0.17 → 3.0.4
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/CONTRIBUTING.md +2 -16
- package/index.js +3 -0
- package/package.json +23 -46
- package/bin/browser.js +0 -24
- package/bin/browser.js.map +0 -1
- package/bin/constants.js +0 -32
- package/bin/constants.js.map +0 -1
- package/bin/downloadImage.js +0 -72
- package/bin/downloadImage.js.map +0 -1
- package/bin/index.js +0 -41
- package/bin/index.js.map +0 -1
- package/bin/local-preview/helper-commands/installDepsCommand.js +0 -12
- package/bin/local-preview/helper-commands/installDepsCommand.js.map +0 -1
- package/bin/local-preview/index.js +0 -154
- package/bin/local-preview/index.js.map +0 -1
- package/bin/local-preview/listener/categorize.js +0 -95
- package/bin/local-preview/listener/categorize.js.map +0 -1
- package/bin/local-preview/listener/categorizeFiles.js +0 -47
- package/bin/local-preview/listener/categorizeFiles.js.map +0 -1
- package/bin/local-preview/listener/generate.js +0 -89
- package/bin/local-preview/listener/generate.js.map +0 -1
- package/bin/local-preview/listener/index.js +0 -200
- package/bin/local-preview/listener/index.js.map +0 -1
- package/bin/local-preview/listener/update.js +0 -24
- package/bin/local-preview/listener/update.js.map +0 -1
- package/bin/local-preview/listener/utils/createPage.js +0 -167
- package/bin/local-preview/listener/utils/createPage.js.map +0 -1
- package/bin/local-preview/listener/utils/fileIsMdxOrMd.js +0 -12
- package/bin/local-preview/listener/utils/fileIsMdxOrMd.js.map +0 -1
- package/bin/local-preview/listener/utils/getOpenApiContext.js +0 -57
- package/bin/local-preview/listener/utils/getOpenApiContext.js.map +0 -1
- package/bin/local-preview/listener/utils/mintConfigFile.js +0 -22
- package/bin/local-preview/listener/utils/mintConfigFile.js.map +0 -1
- package/bin/local-preview/listener/utils/toTitleCase.js +0 -36
- package/bin/local-preview/listener/utils/toTitleCase.js.map +0 -1
- package/bin/local-preview/listener/utils/types.js +0 -2
- package/bin/local-preview/listener/utils/types.js.map +0 -1
- package/bin/local-preview/listener/utils.js +0 -67
- package/bin/local-preview/listener/utils.js.map +0 -1
- package/bin/local-preview/utils/categorizeFiles.js +0 -63
- package/bin/local-preview/utils/categorizeFiles.js.map +0 -1
- package/bin/local-preview/utils/getOpenApiContext.js +0 -58
- package/bin/local-preview/utils/getOpenApiContext.js.map +0 -1
- package/bin/local-preview/utils/injectFavicons.js +0 -72
- package/bin/local-preview/utils/injectFavicons.js.map +0 -1
- package/bin/local-preview/utils/listener.js +0 -116
- package/bin/local-preview/utils/listener.js.map +0 -1
- package/bin/local-preview/utils/metadata.js +0 -118
- package/bin/local-preview/utils/metadata.js.map +0 -1
- package/bin/local-preview/utils/mintConfigFile.js +0 -43
- package/bin/local-preview/utils/mintConfigFile.js.map +0 -1
- package/bin/local-preview/utils/openApiCheck.js +0 -15
- package/bin/local-preview/utils/openApiCheck.js.map +0 -1
- package/bin/local-preview/utils/slugToTitle.js +0 -8
- package/bin/local-preview/utils/slugToTitle.js.map +0 -1
- package/bin/navigation.js +0 -4
- package/bin/navigation.js.map +0 -1
- package/bin/pageTemplate.js +0 -30
- package/bin/pageTemplate.js.map +0 -1
- package/bin/scraping/combineNavWithEmptyGroupTitles.js +0 -20
- package/bin/scraping/combineNavWithEmptyGroupTitles.js.map +0 -1
- package/bin/scraping/detectFramework.js +0 -34
- package/bin/scraping/detectFramework.js.map +0 -1
- package/bin/scraping/downloadAllImages.js +0 -32
- package/bin/scraping/downloadAllImages.js.map +0 -1
- package/bin/scraping/downloadLogoImage.js +0 -13
- package/bin/scraping/downloadLogoImage.js.map +0 -1
- package/bin/scraping/getSitemapLinks.js +0 -18
- package/bin/scraping/getSitemapLinks.js.map +0 -1
- package/bin/scraping/replaceImagePaths.js +0 -17
- package/bin/scraping/replaceImagePaths.js.map +0 -1
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js +0 -43
- package/bin/scraping/scrapeFileGettingFileNameFromUrl.js.map +0 -1
- package/bin/scraping/scrapeGettingFileNameFromUrl.js +0 -13
- package/bin/scraping/scrapeGettingFileNameFromUrl.js.map +0 -1
- package/bin/scraping/scrapePage.js +0 -10
- package/bin/scraping/scrapePage.js.map +0 -1
- package/bin/scraping/scrapePageCommands.js +0 -48
- package/bin/scraping/scrapePageCommands.js.map +0 -1
- package/bin/scraping/scrapeSection.js +0 -12
- package/bin/scraping/scrapeSection.js.map +0 -1
- package/bin/scraping/scrapeSectionCommands.js +0 -60
- package/bin/scraping/scrapeSectionCommands.js.map +0 -1
- package/bin/scraping/site-scrapers/alternateGroupTitle.js +0 -9
- package/bin/scraping/site-scrapers/alternateGroupTitle.js.map +0 -1
- package/bin/scraping/site-scrapers/links-per-group/getDocusaurusLinksPerGroup.js +0 -34
- package/bin/scraping/site-scrapers/links-per-group/getDocusaurusLinksPerGroup.js.map +0 -1
- package/bin/scraping/site-scrapers/links-per-group/getLinksRecursively.js +0 -38
- package/bin/scraping/site-scrapers/links-per-group/getLinksRecursively.js.map +0 -1
- package/bin/scraping/site-scrapers/links-per-group/getLinksRecursivelyGitBook.js +0 -38
- package/bin/scraping/site-scrapers/links-per-group/getLinksRecursivelyGitBook.js.map +0 -1
- package/bin/scraping/site-scrapers/openNestedDocusaurusMenus.js +0 -30
- package/bin/scraping/site-scrapers/openNestedDocusaurusMenus.js.map +0 -1
- package/bin/scraping/site-scrapers/openNestedGitbookMenus.js +0 -17
- package/bin/scraping/site-scrapers/openNestedGitbookMenus.js.map +0 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js +0 -49
- package/bin/scraping/site-scrapers/scrapeDocusaurusPage.js.map +0 -1
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js +0 -30
- package/bin/scraping/site-scrapers/scrapeDocusaurusSection.js.map +0 -1
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js +0 -47
- package/bin/scraping/site-scrapers/scrapeGitBookPage.js.map +0 -1
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js +0 -52
- package/bin/scraping/site-scrapers/scrapeGitBookSection.js.map +0 -1
- package/bin/scraping/site-scrapers/scrapeReadMePage.js +0 -36
- package/bin/scraping/site-scrapers/scrapeReadMePage.js.map +0 -1
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js +0 -44
- package/bin/scraping/site-scrapers/scrapeReadMeSection.js.map +0 -1
- package/bin/util.js +0 -129
- package/bin/util.js.map +0 -1
- package/bin/validation/isValidLink.js +0 -11
- package/bin/validation/isValidLink.js.map +0 -1
- package/bin/validation/stopIfInvalidLink.js +0 -9
- package/bin/validation/stopIfInvalidLink.js.map +0 -1
- package/scraper.md +0 -120
- package/src/browser.ts +0 -24
- package/src/constants.ts +0 -40
- package/src/downloadImage.ts +0 -93
- package/src/index.ts +0 -95
- package/src/local-preview/helper-commands/installDepsCommand.ts +0 -13
- package/src/local-preview/index.ts +0 -195
- package/src/local-preview/listener/categorize.ts +0 -105
- package/src/local-preview/listener/generate.ts +0 -110
- package/src/local-preview/listener/index.ts +0 -228
- package/src/local-preview/listener/update.ts +0 -27
- package/src/local-preview/listener/utils/createPage.ts +0 -211
- package/src/local-preview/listener/utils/getOpenApiContext.ts +0 -77
- package/src/local-preview/listener/utils/mintConfigFile.ts +0 -28
- package/src/local-preview/listener/utils/toTitleCase.ts +0 -40
- package/src/local-preview/listener/utils/types.ts +0 -16
- package/src/local-preview/listener/utils.ts +0 -78
- package/src/scraping/combineNavWithEmptyGroupTitles.ts +0 -21
- package/src/scraping/detectFramework.ts +0 -41
- package/src/scraping/downloadAllImages.ts +0 -57
- package/src/scraping/downloadLogoImage.ts +0 -24
- package/src/scraping/getSitemapLinks.ts +0 -18
- package/src/scraping/replaceImagePaths.ts +0 -21
- package/src/scraping/scrapeFileGettingFileNameFromUrl.ts +0 -86
- package/src/scraping/scrapeGettingFileNameFromUrl.ts +0 -54
- package/src/scraping/scrapePage.ts +0 -24
- package/src/scraping/scrapePageCommands.ts +0 -57
- package/src/scraping/scrapeSection.ts +0 -28
- package/src/scraping/scrapeSectionCommands.ts +0 -102
- package/src/scraping/site-scrapers/alternateGroupTitle.ts +0 -8
- package/src/scraping/site-scrapers/links-per-group/getDocusaurusLinksPerGroup.ts +0 -44
- package/src/scraping/site-scrapers/links-per-group/getLinksRecursively.ts +0 -45
- package/src/scraping/site-scrapers/links-per-group/getLinksRecursivelyGitBook.ts +0 -46
- package/src/scraping/site-scrapers/openNestedDocusaurusMenus.ts +0 -42
- package/src/scraping/site-scrapers/openNestedGitbookMenus.ts +0 -24
- package/src/scraping/site-scrapers/scrapeDocusaurusPage.ts +0 -81
- package/src/scraping/site-scrapers/scrapeDocusaurusSection.ts +0 -63
- package/src/scraping/site-scrapers/scrapeGitBookPage.ts +0 -74
- package/src/scraping/site-scrapers/scrapeGitBookSection.ts +0 -80
- package/src/scraping/site-scrapers/scrapeReadMePage.ts +0 -60
- package/src/scraping/site-scrapers/scrapeReadMeSection.ts +0 -70
- package/src/types.d.ts +0 -29
- package/src/util.ts +0 -161
- package/src/validation/isValidLink.ts +0 -9
- package/src/validation/stopIfInvalidLink.ts +0 -9
- package/tsconfig.json +0 -18
package/src/util.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "fs";
|
|
2
|
-
import Ora from "ora";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import shell from "shelljs";
|
|
5
|
-
import stopIfInvalidLink from "./validation/stopIfInvalidLink.js";
|
|
6
|
-
|
|
7
|
-
export const MintConfig = (
|
|
8
|
-
name: string,
|
|
9
|
-
color: string,
|
|
10
|
-
ctaName: string,
|
|
11
|
-
ctaUrl: string,
|
|
12
|
-
filename: string
|
|
13
|
-
) => {
|
|
14
|
-
return {
|
|
15
|
-
name,
|
|
16
|
-
logo: "",
|
|
17
|
-
favicon: "",
|
|
18
|
-
colors: {
|
|
19
|
-
primary: color,
|
|
20
|
-
},
|
|
21
|
-
topbarLinks: [],
|
|
22
|
-
topbarCtaButton: {
|
|
23
|
-
name: ctaName,
|
|
24
|
-
url: ctaUrl,
|
|
25
|
-
},
|
|
26
|
-
anchors: [],
|
|
27
|
-
navigation: [
|
|
28
|
-
{
|
|
29
|
-
group: "Home",
|
|
30
|
-
pages: [filename],
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
// footerSocials: {}, // support object type for footer tyoes
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const Page = (
|
|
38
|
-
title: string,
|
|
39
|
-
description?: string,
|
|
40
|
-
markdown?: string
|
|
41
|
-
) => {
|
|
42
|
-
// If we are an empty String we want to add two quotes,
|
|
43
|
-
// if we added as we went we would detect the first quote
|
|
44
|
-
// as the closing quote.
|
|
45
|
-
const startsWithQuote = title.startsWith('"');
|
|
46
|
-
const endsWithQuote = title.startsWith('"');
|
|
47
|
-
if (!startsWithQuote) {
|
|
48
|
-
title = '"' + title;
|
|
49
|
-
}
|
|
50
|
-
if (!endsWithQuote) {
|
|
51
|
-
title = title + '"';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const optionalDescription = description
|
|
55
|
-
? `\ndescription: "${description}"`
|
|
56
|
-
: "";
|
|
57
|
-
return `---\ntitle: ${title}${optionalDescription}\n---\n\n${markdown}`;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export function getOrigin(url: string) {
|
|
61
|
-
// eg. https://google.com -> https://google.com
|
|
62
|
-
// https://google.com/page -> https://google.com
|
|
63
|
-
return new URL(url).origin;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function objToReadableString(objs: MintNavigationEntry[]) {
|
|
67
|
-
// Two spaces as indentation
|
|
68
|
-
return objs.map((obj) => JSON.stringify(obj, null, 2)).join(",\n");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const toFilename = (title: string) => {
|
|
72
|
-
// Gets rid of special characters at the start and end
|
|
73
|
-
// of the name by converting to spaces then using trim.
|
|
74
|
-
return title
|
|
75
|
-
.replace(/[^a-z0-9]/gi, " ")
|
|
76
|
-
.trim()
|
|
77
|
-
.replace(/ /g, "-")
|
|
78
|
-
.toLowerCase();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const addMdx = (fileName: string) => {
|
|
82
|
-
if (fileName.endsWith(".mdx")) {
|
|
83
|
-
return fileName;
|
|
84
|
-
}
|
|
85
|
-
return fileName + ".mdx";
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const createPage = (
|
|
89
|
-
title: string,
|
|
90
|
-
description?: string,
|
|
91
|
-
markdown?: string,
|
|
92
|
-
overwrite: boolean = false,
|
|
93
|
-
rootDir: string = "",
|
|
94
|
-
fileName?: string
|
|
95
|
-
) => {
|
|
96
|
-
const writePath = path.join(rootDir, addMdx(fileName || toFilename(title)));
|
|
97
|
-
|
|
98
|
-
// Create the folders needed if they're missing
|
|
99
|
-
mkdirSync(rootDir, { recursive: true });
|
|
100
|
-
|
|
101
|
-
// Write the page to memory
|
|
102
|
-
if (overwrite) {
|
|
103
|
-
writeFileSync(writePath, Page(title, description, markdown));
|
|
104
|
-
console.log("✏️ - " + writePath);
|
|
105
|
-
} else {
|
|
106
|
-
try {
|
|
107
|
-
writeFileSync(writePath, Page(title, description, markdown), {
|
|
108
|
-
flag: "wx",
|
|
109
|
-
});
|
|
110
|
-
console.log("✏️ - " + writePath);
|
|
111
|
-
} catch (e) {
|
|
112
|
-
// We do a try-catch instead of an if-statement to avoid a race condition
|
|
113
|
-
// of the file being created after we started writing.
|
|
114
|
-
if (e.code === "EEXIST") {
|
|
115
|
-
console.log(`❌ Skipping existing file ${writePath}`);
|
|
116
|
-
} else {
|
|
117
|
-
console.error(e);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export function getHrefFromArgs(argv: any) {
|
|
124
|
-
const href = argv.url;
|
|
125
|
-
stopIfInvalidLink(href);
|
|
126
|
-
return href;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export const buildLogger = (startText: string = "") => {
|
|
130
|
-
const logger = Ora().start(startText);
|
|
131
|
-
return logger;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const getFileExtension = (filename: string) => {
|
|
135
|
-
const ext = filename.substring(
|
|
136
|
-
filename.lastIndexOf(".") + 1,
|
|
137
|
-
filename.length
|
|
138
|
-
);
|
|
139
|
-
if (filename === ext) return undefined;
|
|
140
|
-
return ext;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const fileBelongsInPagesFolder = (filename: string) => {
|
|
144
|
-
const extension = getFileExtension(filename);
|
|
145
|
-
return (
|
|
146
|
-
extension &&
|
|
147
|
-
(extension === "mdx" || extension === "md" || extension === "tsx")
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const ensureYarn = (logger: any) => {
|
|
152
|
-
const yarnInstalled = shell.which("yarn");
|
|
153
|
-
if (!yarnInstalled) {
|
|
154
|
-
logger.fail(`yarn must be installed, run
|
|
155
|
-
|
|
156
|
-
npm install --global yarn
|
|
157
|
-
|
|
158
|
-
`);
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import isValidLink from "./isValidLink.js";
|
|
2
|
-
|
|
3
|
-
export default function stopIfInvalidLink(href: string) {
|
|
4
|
-
if (!isValidLink(href)) {
|
|
5
|
-
console.log("Invalid link: " + href);
|
|
6
|
-
console.log("Make sure the link starts with http:// or https://");
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
9
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "ES2020",
|
|
4
|
-
"moduleResolution": "node",
|
|
5
|
-
"target": "es2020",
|
|
6
|
-
"lib": ["es2020", "dom", "ES2021.String"],
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"outDir": "bin",
|
|
9
|
-
"baseUrl": ".",
|
|
10
|
-
"paths": {
|
|
11
|
-
"*": ["node_modules/*", "src/types/*"]
|
|
12
|
-
},
|
|
13
|
-
"emitDecoratorMetadata": true,
|
|
14
|
-
"experimentalDecorators": true,
|
|
15
|
-
"esModuleInterop": true
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*"]
|
|
18
|
-
}
|