@alauda/doom 0.9.1 → 0.10.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.
@@ -1,7 +1,8 @@
1
- import fs from '@rspress/shared/fs-extra';
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
2
3
  import { logger } from '@rspress/shared/logger';
3
4
  import { loadFrontMatter } from '@rspress/shared/node-utils';
4
- import path from 'node:path';
5
+ import { pathExists } from '../../utils/index.js';
5
6
  export async function detectFilePath(rawPath, extensions) {
6
7
  // The params doesn't have extension name, so we need to try to find the file with the extension name.
7
8
  let realPath = rawPath;
@@ -9,7 +10,7 @@ export async function detectFilePath(rawPath, extensions) {
9
10
  // pathname may contain .json, see issue: https://github.com/web-infra-dev/rspress/issues/951
10
11
  if (!extensions.includes(fileExtname)) {
11
12
  const pathWithExtension = extensions.map((ext) => `${rawPath}${ext}`);
12
- const pathExistInfo = await Promise.all(pathWithExtension.map((p) => fs.pathExists(p)));
13
+ const pathExistInfo = await Promise.all(pathWithExtension.map((p) => pathExists(p)));
13
14
  const findPath = pathWithExtension.find((_, i) => pathExistInfo[i]);
14
15
  // file may be public resource, see issue: https://github.com/web-infra-dev/rspress/issues/1052
15
16
  if (!fileExtname || findPath) {
@@ -49,13 +50,7 @@ export async function extractInfoFromFrontmatter(filePath, rootDir, extensions)
49
50
  }
50
51
  export function combineWalkResult(walks, versions) {
51
52
  return walks.reduce((acc, cur, curIndex) => ({
52
- nav: {
53
- ...acc.nav,
54
- [versions[curIndex] || 'default']: cur.nav,
55
- },
53
+ nav: { ...acc.nav, [versions[curIndex] || 'default']: cur.nav },
56
54
  sidebar: { ...acc.sidebar, ...cur.sidebar },
57
- }), {
58
- nav: {},
59
- sidebar: {},
60
- });
55
+ }), { nav: {}, sidebar: {} });
61
56
  }
@@ -1,10 +1,11 @@
1
+ import fs from 'node:fs/promises';
1
2
  import path from 'node:path';
2
3
  import { isExternalUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase, } from '@rspress/shared';
3
- import fs from '@rspress/shared/fs-extra';
4
4
  import { logger } from '@rspress/shared/logger';
5
5
  import { unset } from 'es-toolkit/compat';
6
6
  import picomatch from 'picomatch';
7
7
  import { detectFilePath, extractInfoFromFrontmatter } from './utils.js';
8
+ import { pathExists, readJson } from '../../utils/index.js';
8
9
  const sidebarSorter = (a, b) => {
9
10
  const aWeight = 'weight' in a && a.weight != null ? a.weight : 100;
10
11
  const bWeight = 'weight' in b && b.weight != null ? b.weight : 100;
@@ -42,7 +43,7 @@ const processSideMeta = (sideMeta, extensions, excludeRoutes) => {
42
43
  return result;
43
44
  };
44
45
  export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, extensions, ignoredDirs, excludeRoutes) {
45
- if (!(await fs.exists(workDir))) {
46
+ if (!(await pathExists(workDir))) {
46
47
  logger.error('[plugin-auto-sidebar]', `Generate sidebar meta error: ${workDir} not exists`);
47
48
  }
48
49
  const addRoutePrefix = (link) => `${routePrefix}${removeLeadingSlash(link)}`;
@@ -54,7 +55,7 @@ export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, exten
54
55
  // Get the sidebar config from the `_meta.json` file
55
56
  try {
56
57
  // Don't use require to avoid require cache, which make hmr not work.
57
- sideMeta = (await fs.readJSON(metaFile, 'utf8'));
58
+ sideMeta = await readJson(metaFile);
58
59
  }
59
60
  catch {
60
61
  // If the `_meta.json` file doesn't exist, we will generate the sidebar config from the directory structure.
@@ -88,10 +89,10 @@ export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, exten
88
89
  const { title } = await extractInfoFromFrontmatter(filePath, rootDir, extensions);
89
90
  label = title;
90
91
  };
91
- if (fs.existsSync(mdxFilePath)) {
92
+ if (await pathExists(mdxFilePath)) {
92
93
  await setLabelFromFilePath(mdxFilePath);
93
94
  }
94
- else if (fs.existsSync(mdFilePath)) {
95
+ else if (await pathExists(mdFilePath)) {
95
96
  await setLabelFromFilePath(mdFilePath);
96
97
  }
97
98
  return {
@@ -0,0 +1,2 @@
1
+ export declare function pathExists(path: string): Promise<boolean>;
2
+ export declare function readJson<T>(path: string): Promise<T>;
@@ -0,0 +1,14 @@
1
+ import fs from 'fs/promises';
2
+ export async function pathExists(path) {
3
+ try {
4
+ await fs.access(path);
5
+ return true;
6
+ }
7
+ catch {
8
+ return false;
9
+ }
10
+ }
11
+ export async function readJson(path) {
12
+ const raw = await fs.readFile(path, 'utf8');
13
+ return JSON.parse(raw);
14
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './constants.js';
2
+ export * from './fs.js';
2
3
  export * from './git.js';
3
4
  export * from './helpers.js';
4
5
  export * from './types.js';
@@ -1,4 +1,5 @@
1
1
  export * from './constants.js';
2
+ export * from './fs.js';
2
3
  export * from './git.js';
3
4
  export * from './helpers.js';
4
5
  export * from './types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -38,15 +38,15 @@
38
38
  "swc-node": "node --enable-source-maps --import @swc-node/register/esm-register"
39
39
  },
40
40
  "dependencies": {
41
- "@inquirer/prompts": "^7.2.3",
41
+ "@inquirer/prompts": "^7.3.1",
42
42
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
43
- "@rspress/core": "1.40.0",
44
- "@shikijs/transformers": "^2.1.0",
43
+ "@rspress/core": "1.41.1",
44
+ "@shikijs/transformers": "^2.3.2",
45
45
  "chokidar": "^4.0.3",
46
46
  "clsx": "^2.1.1",
47
47
  "commander": "^13.1.0",
48
48
  "ejs": "^3.1.10",
49
- "es-toolkit": "^1.31.0",
49
+ "es-toolkit": "^1.32.0",
50
50
  "mermaid": "^11.4.1",
51
51
  "openapi-types": "^12.1.3",
52
52
  "picomatch": "^4.0.2",
@@ -55,34 +55,33 @@
55
55
  "remark-directive": "^2.0.1",
56
56
  "remark-frontmatter": "^4.0.1",
57
57
  "remark-gfm": "^3.0.1",
58
- "shiki": "^2.1.0",
58
+ "shiki": "^2.3.2",
59
59
  "simple-git": "^3.27.0",
60
60
  "swagger2openapi": "^7.0.8",
61
61
  "tinyglobby": "^0.2.10",
62
- "type-fest": "^4.33.0",
62
+ "type-fest": "^4.34.1",
63
63
  "yaml": "^2.7.0",
64
64
  "yoctocolors": "^2.1.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@eslint/js": "^9.18.0",
67
+ "@eslint/js": "^9.20.0",
68
68
  "@swc-node/register": "^1.10.9",
69
- "@swc/core": "1.10.9",
69
+ "@swc/core": "1.10.15",
70
70
  "@types/ejs": "^3.1.5",
71
71
  "@types/eslint__js": "^8.42.3",
72
- "@types/fs-extra": "^11.0.4",
73
- "@types/node": "^18.19.71",
72
+ "@types/node": "^18.19.75",
74
73
  "@types/picomatch": "^3.0.2",
75
74
  "@types/react-dom": "^18.3.5",
76
75
  "@types/swagger2openapi": "^7.0.4",
77
76
  "@unts/patch-package": "^8.0.0",
78
- "eslint": "^9.18.0",
79
- "lint-staged": "^15.4.1",
77
+ "eslint": "^9.20.0",
78
+ "lint-staged": "^15.4.3",
80
79
  "npm-run-all2": "^7.0.2",
81
- "prettier": "^3.4.2",
80
+ "prettier": "^3.5.0",
82
81
  "prettier-plugin-pkg": "^0.18.1",
83
82
  "simple-git-hooks": "^2.11.1",
84
83
  "typescript": "^5.7.3",
85
- "typescript-eslint": "^8.21.0"
84
+ "typescript-eslint": "^8.23.0"
86
85
  },
87
86
  "publishConfig": {
88
87
  "access": "public"