@docsalot/previewing 0.1.0-beta.7 → 0.1.0-beta.9
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.
|
Binary file
|
|
@@ -4,14 +4,14 @@ import child_process from "child_process";
|
|
|
4
4
|
import open from "open";
|
|
5
5
|
import fse from "fs-extra";
|
|
6
6
|
import shell from "shelljs";
|
|
7
|
-
import { HOME_DIR, CLIENT_PATH, MINT_PATH, } from "../constants.js";
|
|
7
|
+
import { HOME_DIR, CLIENT_PATH, CMD_EXEC_PATH, MINT_PATH, } from "../constants.js";
|
|
8
8
|
import { buildLogger } from "../util.js";
|
|
9
9
|
import listener from "./listener/index.js";
|
|
10
10
|
import { getConfigPath } from "./listener/utils/mintConfigFile.js";
|
|
11
11
|
import installDepsCommand from "./helper-commands/installDepsCommand.js";
|
|
12
12
|
import syncLocalContentCommand from "./helper-commands/syncLocalContentCommand.js";
|
|
13
13
|
const checkForLayoutJson = async (logger) => {
|
|
14
|
-
const configPath = await getConfigPath(
|
|
14
|
+
const configPath = await getConfigPath(CMD_EXEC_PATH);
|
|
15
15
|
if (configPath == null) {
|
|
16
16
|
logger.fail("Must be ran in a directory where a layout.json file exists.");
|
|
17
17
|
process.exit(1);
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { getFileList } from "@docsalot/prebuild";
|
|
5
5
|
import { getFileExtension, openApiCheck } from "./utils.js";
|
|
6
|
+
const shouldIgnorePath = (filename) => {
|
|
7
|
+
const normalized = filename.replace(/\\/g, "/").toLowerCase();
|
|
8
|
+
return (normalized.startsWith("/node_modules/") ||
|
|
9
|
+
normalized.includes("/node_modules/") ||
|
|
10
|
+
normalized.startsWith("/.git/") ||
|
|
11
|
+
normalized.includes("/.git/") ||
|
|
12
|
+
normalized.startsWith("/.next/") ||
|
|
13
|
+
normalized.includes("/.next/") ||
|
|
14
|
+
normalized.startsWith("/.docsalot/") ||
|
|
15
|
+
normalized.includes("/.docsalot/"));
|
|
16
|
+
};
|
|
6
17
|
export const categorizeFiles = async (contentDirectoryPath) => {
|
|
7
18
|
const allFilesInCmdExecutionPath = getFileList(contentDirectoryPath);
|
|
8
19
|
const contentFilenames = [];
|
|
@@ -11,6 +22,9 @@ export const categorizeFiles = async (contentDirectoryPath) => {
|
|
|
11
22
|
const openApiFiles = [];
|
|
12
23
|
const snippets = [];
|
|
13
24
|
allFilesInCmdExecutionPath.forEach((filename) => {
|
|
25
|
+
if (shouldIgnorePath(filename)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
14
28
|
promises.push((async () => {
|
|
15
29
|
const extension = getFileExtension(filename);
|
|
16
30
|
let isOpenApi = false;
|
|
@@ -27,18 +27,31 @@ const pageMetadataKeys = [
|
|
|
27
27
|
const generateDecoratedMintNavigationFromPages = (filenamePageMetadataMap, mintConfigNav) => {
|
|
28
28
|
const filenames = Object.keys(filenamePageMetadataMap);
|
|
29
29
|
const createNav = (nav) => {
|
|
30
|
+
if (!nav || !Array.isArray(nav.pages)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
30
33
|
return {
|
|
31
34
|
group: nav.group,
|
|
32
35
|
version: nav?.version,
|
|
33
|
-
pages: nav.pages
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
pages: nav.pages
|
|
37
|
+
.map((page) => {
|
|
38
|
+
if (typeof page === "string") {
|
|
39
|
+
if (filenames.includes(page)) {
|
|
40
|
+
return filenamePageMetadataMap[page];
|
|
41
|
+
}
|
|
42
|
+
// Keep local preview resilient when navigation references missing pages.
|
|
43
|
+
return null;
|
|
36
44
|
}
|
|
37
45
|
return createNav(page);
|
|
38
|
-
})
|
|
46
|
+
})
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.map((entry) => entry),
|
|
39
49
|
};
|
|
40
50
|
};
|
|
41
|
-
return mintConfigNav
|
|
51
|
+
return (mintConfigNav || [])
|
|
52
|
+
.map((nav) => createNav(nav))
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.map((entry) => entry);
|
|
42
55
|
};
|
|
43
56
|
const createFilenamePageMetadataMap = async (contentDirectoryPath, contentFilenames, openApiFiles, clientPath, writeFiles = false) => {
|
|
44
57
|
let pagesAcc = {};
|
|
@@ -4,13 +4,13 @@ import child_process from "child_process";
|
|
|
4
4
|
import open from "open";
|
|
5
5
|
import fse from "fs-extra";
|
|
6
6
|
import shell from "shelljs";
|
|
7
|
-
import { HOME_DIR, CLIENT_PATH, MINT_PATH, } from "../constants.js";
|
|
7
|
+
import { HOME_DIR, CLIENT_PATH, CMD_EXEC_PATH, MINT_PATH, } from "../constants.js";
|
|
8
8
|
import { buildLogger } from "../util.js";
|
|
9
9
|
import { getConfigPath } from "./listener/utils/mintConfigFile.js";
|
|
10
10
|
import installDepsCommand from "./helper-commands/installDepsCommand.js";
|
|
11
11
|
import syncLocalContentCommand from "./helper-commands/syncLocalContentCommand.js";
|
|
12
12
|
const checkForLayoutJson = async (logger) => {
|
|
13
|
-
const configPath = await getConfigPath(
|
|
13
|
+
const configPath = await getConfigPath(CMD_EXEC_PATH);
|
|
14
14
|
if (configPath == null) {
|
|
15
15
|
logger.fail("Must be ran in a directory where a layout.json file exists.");
|
|
16
16
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsalot/previewing",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.9",
|
|
4
4
|
"description": "Preview DocsALot docs locally",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
33
|
-
"@docsalot/prebuild": "^0.1.0-beta.
|
|
34
|
-
"@docsalot/validation": "^0.1.0-beta.
|
|
33
|
+
"@docsalot/prebuild": "^0.1.0-beta.9",
|
|
34
|
+
"@docsalot/validation": "^0.1.0-beta.9",
|
|
35
35
|
"@octokit/rest": "^19.0.5",
|
|
36
36
|
"axios": "^1.2.2",
|
|
37
37
|
"chalk": "^5.1.0",
|