@docsalot/previewing 0.1.0-beta.0

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.
Files changed (37) hide show
  1. package/README.md +17 -0
  2. package/dist/constants.d.ts +9 -0
  3. package/dist/constants.js +37 -0
  4. package/dist/downloadImage.d.ts +4 -0
  5. package/dist/downloadImage.js +81 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.js +4 -0
  8. package/dist/local-preview/helper-commands/installDepsCommand.d.ts +2 -0
  9. package/dist/local-preview/helper-commands/installDepsCommand.js +11 -0
  10. package/dist/local-preview/index.d.ts +3 -0
  11. package/dist/local-preview/index.js +159 -0
  12. package/dist/local-preview/listener/categorize.d.ts +8 -0
  13. package/dist/local-preview/listener/categorize.js +96 -0
  14. package/dist/local-preview/listener/generate.d.ts +12 -0
  15. package/dist/local-preview/listener/generate.js +73 -0
  16. package/dist/local-preview/listener/index.d.ts +2 -0
  17. package/dist/local-preview/listener/index.js +200 -0
  18. package/dist/local-preview/listener/update.d.ts +2 -0
  19. package/dist/local-preview/listener/update.js +23 -0
  20. package/dist/local-preview/listener/utils/createPage.d.ts +11 -0
  21. package/dist/local-preview/listener/utils/createPage.js +169 -0
  22. package/dist/local-preview/listener/utils/getOpenApiContext.d.ts +21 -0
  23. package/dist/local-preview/listener/utils/getOpenApiContext.js +57 -0
  24. package/dist/local-preview/listener/utils/mintConfigFile.d.ts +2 -0
  25. package/dist/local-preview/listener/utils/mintConfigFile.js +21 -0
  26. package/dist/local-preview/listener/utils/toTitleCase.d.ts +1 -0
  27. package/dist/local-preview/listener/utils/toTitleCase.js +35 -0
  28. package/dist/local-preview/listener/utils/types.d.ts +2 -0
  29. package/dist/local-preview/listener/utils/types.js +1 -0
  30. package/dist/local-preview/listener/utils.d.ts +13 -0
  31. package/dist/local-preview/listener/utils.js +53 -0
  32. package/dist/local-preview/prod.d.ts +3 -0
  33. package/dist/local-preview/prod.js +130 -0
  34. package/dist/tsconfig.tsbuildinfo +1 -0
  35. package/dist/util.d.ts +28 -0
  36. package/dist/util.js +92 -0
  37. package/package.json +81 -0
package/dist/util.js ADDED
@@ -0,0 +1,92 @@
1
+ import Ora from "ora";
2
+ import shell from "shelljs";
3
+ export const MintConfig = (name, color, ctaName, ctaUrl, filename) => {
4
+ return {
5
+ name,
6
+ logo: "",
7
+ favicon: "",
8
+ colors: {
9
+ primary: color,
10
+ },
11
+ topbarLinks: [],
12
+ topbarCtaButton: {
13
+ name: ctaName,
14
+ url: ctaUrl,
15
+ },
16
+ anchors: [],
17
+ navigation: [
18
+ {
19
+ group: "Home",
20
+ pages: [filename],
21
+ },
22
+ ],
23
+ // footerSocials: {}, // support object type for footer tyoes
24
+ };
25
+ };
26
+ export const Page = (title, description, markdown) => {
27
+ // If we are an empty String we want to add two quotes,
28
+ // if we added as we went we would detect the first quote
29
+ // as the closing quote.
30
+ const startsWithQuote = title.startsWith('"');
31
+ const endsWithQuote = title.startsWith('"');
32
+ if (!startsWithQuote) {
33
+ title = '"' + title;
34
+ }
35
+ if (!endsWithQuote) {
36
+ title = title + '"';
37
+ }
38
+ const optionalDescription = description
39
+ ? `\ndescription: "${description}"`
40
+ : "";
41
+ return `---\ntitle: ${title}${optionalDescription}\n---\n\n${markdown}`;
42
+ };
43
+ export function getOrigin(url) {
44
+ // eg. https://google.com -> https://google.com
45
+ // https://google.com/page -> https://google.com
46
+ return new URL(url).origin;
47
+ }
48
+ export function objToReadableString(objs) {
49
+ // Two spaces as indentation
50
+ return objs.map((obj) => JSON.stringify(obj, null, 2)).join(",\n");
51
+ }
52
+ export const toFilename = (title) => {
53
+ // Gets rid of special characters at the start and end
54
+ // of the name by converting to spaces then using trim.
55
+ return title
56
+ .replace(/[^a-z0-9]/gi, " ")
57
+ .trim()
58
+ .replace(/ /g, "-")
59
+ .toLowerCase();
60
+ };
61
+ export const addMdx = (fileName) => {
62
+ if (fileName.endsWith(".mdx")) {
63
+ return fileName;
64
+ }
65
+ return fileName + ".mdx";
66
+ };
67
+ export const buildLogger = (startText = "") => {
68
+ const logger = Ora().start(startText);
69
+ return logger;
70
+ };
71
+ export const getFileExtension = (filename) => {
72
+ const ext = filename.substring(filename.lastIndexOf(".") + 1, filename.length);
73
+ if (filename === ext)
74
+ return undefined;
75
+ return ext;
76
+ };
77
+ export const fileBelongsInPagesFolder = (filename) => {
78
+ const extension = getFileExtension(filename);
79
+ return (extension &&
80
+ (extension === "mdx" || extension === "md" || extension === "tsx"));
81
+ };
82
+ export const ensureYarn = (logger) => {
83
+ const yarnInstalled = shell.which("yarn");
84
+ if (!yarnInstalled) {
85
+ logger.fail(`yarn must be installed, run
86
+
87
+ npm install --global yarn
88
+
89
+ `);
90
+ process.exit(1);
91
+ }
92
+ };
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@docsalot/previewing",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "Preview DocsALot docs locally",
5
+ "engines": {
6
+ "node": ">=18.0.0"
7
+ },
8
+ "author": "SlashML Corp.",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/slashml/docsalot",
12
+ "directory": "packages/docsalot-previewing"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/slashml/docsalot/issues"
16
+ },
17
+ "license": "Elastic-2.0",
18
+ "keywords": [
19
+ "docsalot",
20
+ "docs",
21
+ "previewing"
22
+ ],
23
+ "type": "module",
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "prepare": "npm run build",
35
+ "build": "tsc",
36
+ "watch": "tsc --watch",
37
+ "lint": "eslint . --cache"
38
+ },
39
+ "dependencies": {
40
+ "@apidevtools/swagger-parser": "^10.1.0",
41
+ "@docsalot/prebuild": "0.1.0-beta.0",
42
+ "@docsalot/validation": "0.1.0-beta.0",
43
+ "@octokit/rest": "^19.0.5",
44
+ "axios": "^1.2.2",
45
+ "chalk": "^5.1.0",
46
+ "chokidar": "^3.5.3",
47
+ "fs-extra": "^11.1.0",
48
+ "gray-matter": "^4.0.3",
49
+ "inquirer": "^9.1.0",
50
+ "is-absolute-url": "^4.0.1",
51
+ "is-internet-available": "^3.1.0",
52
+ "open": "^8.4.0",
53
+ "openapi-types": "^12.0.2",
54
+ "ora": "^6.1.2",
55
+ "remark": "^14.0.2",
56
+ "remark-frontmatter": "^4.0.1",
57
+ "remark-gfm": "^3.0.1",
58
+ "remark-mdx": "^2.2.1",
59
+ "shelljs": "^0.8.5",
60
+ "unist-util-visit": "^4.1.1",
61
+ "yargs": "^17.6.0"
62
+ },
63
+ "devDependencies": {
64
+ "@mintlify/eslint-config": "1.0.3",
65
+ "@mintlify/eslint-config-typescript": "1.0.7",
66
+ "@mintlify/ts-config": "1.0.7",
67
+ "@tsconfig/recommended": "1.x",
68
+ "@types/fs-extra": "^9.0.13",
69
+ "@types/inquirer": "^9.0.1",
70
+ "@types/node": "^18.7.13",
71
+ "@types/shelljs": "^0.8.11",
72
+ "@types/yargs": "^17.0.13",
73
+ "@typescript-eslint/eslint-plugin": "5.x",
74
+ "@typescript-eslint/parser": "5.x",
75
+ "eslint": "8.x",
76
+ "eslint-config-prettier": "8.x",
77
+ "eslint-plugin-unused-imports": "2.x",
78
+ "prettier": "2.x",
79
+ "typescript": "^4.8.2"
80
+ }
81
+ }