@alauda/doom 0.19.6 → 0.20.1

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/lib/cli/index.js CHANGED
@@ -37,6 +37,8 @@ program
37
37
  .option('-i, --ignore [boolean]', 'Ignore internal routes', parseBoolean, false)
38
38
  .option('-d, --download [boolean]', 'Display download pdf link on nav bar', parseBoolean, false)
39
39
  .option('-e, --export [boolean]', 'Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically', parseBoolean, false)
40
+ .option('-I, --include-language <language...>', 'Include **only** the specific language(s), `en ru` for example')
41
+ .option('-E, --exclude-language <language...>', 'Include all languages except the specific language(s), `ru` for example')
40
42
  .option('-n, --no-open [boolean]', 'Do not open the browser after starting the server')
41
43
  .command('dev', { isDefault: true })
42
44
  .description('Start the development server')
@@ -1,6 +1,6 @@
1
1
  import { type UserConfig } from '@rspress/core';
2
2
  import type { GlobalCliOptions } from '../types.js';
3
- export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, }?: GlobalCliOptions): Promise<{
3
+ export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, includeLanguage: includeLanguages, excludeLanguage: excludeLanguages, }?: GlobalCliOptions): Promise<{
4
4
  config: UserConfig;
5
5
  filepath?: string;
6
6
  }>;
@@ -1,4 +1,4 @@
1
- import fs from 'node:fs';
1
+ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { nodeTypes } from '@mdx-js/mdx';
4
4
  import { pluginYaml } from '@rsbuild/plugin-yaml';
@@ -11,23 +11,30 @@ import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
11
11
  import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
12
12
  import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
13
13
  const DEFAULT_LOGO = '/logo.svg';
14
- const zhLocaleConfig = {
15
- searchPlaceholderText: '搜索文档',
16
- searchNoResultsText: '未搜索到相关结果',
17
- searchSuggestedQueryText: '可更换不同的关键字后重试',
18
- outlineTitle: '本页概览',
19
- prevPageText: '上一页',
20
- nextPageText: '下一页',
14
+ const KNOWN_LOCALE_CONFIGS = {
15
+ en: {
16
+ label: 'English',
17
+ },
18
+ zh: {
19
+ label: '简体中文',
20
+ searchPlaceholderText: '搜索文档',
21
+ searchNoResultsText: '未搜索到相关结果',
22
+ searchSuggestedQueryText: '可更换不同的关键字后重试',
23
+ outlineTitle: '本页概览',
24
+ prevPageText: '上一页',
25
+ nextPageText: '下一页',
26
+ },
27
+ ru: {
28
+ label: 'Русский',
29
+ searchPlaceholderText: 'Поиск документов',
30
+ searchNoResultsText: 'Не найдено соответствующих результатов',
31
+ searchSuggestedQueryText: 'Попробуйте изменить ключевые слова и повторить поиск',
32
+ outlineTitle: 'Обзор страницы',
33
+ prevPageText: 'Предыдущая страница',
34
+ nextPageText: 'Следующая страница',
35
+ },
21
36
  };
22
- const ruLocaleConfig = {
23
- searchPlaceholderText: 'Поиск документов',
24
- searchNoResultsText: 'Не найдено соответствующих результатов',
25
- searchSuggestedQueryText: 'Попробуйте изменить ключевые слова и повторить поиск',
26
- outlineTitle: 'Обзор страницы',
27
- prevPageText: 'Предыдущая страница',
28
- nextPageText: 'Следующая страница',
29
- };
30
- const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, }) => {
37
+ const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, includeLanguages, excludeLanguages, }) => {
31
38
  const fallbackToZh = 'lang' in config && !config.lang;
32
39
  root = resolveDocRoot(CWD, root, config.root);
33
40
  const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
@@ -35,6 +42,32 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
35
42
  if (version && !isExplicitlyUnversioned(version)) {
36
43
  base = userBase + `${version}/`;
37
44
  }
45
+ let locales;
46
+ if (!fallbackToZh) {
47
+ const dirents = await fs.readdir(root, { withFileTypes: true });
48
+ for (const dirent of dirents) {
49
+ const { name } = dirent;
50
+ if (!dirent.isDirectory() || ['public', 'shared'].includes(name)) {
51
+ continue;
52
+ }
53
+ if (includeLanguages?.length) {
54
+ if (!includeLanguages.includes(name)) {
55
+ continue;
56
+ }
57
+ }
58
+ else if (excludeLanguages?.length) {
59
+ if (excludeLanguages.includes(name)) {
60
+ continue;
61
+ }
62
+ }
63
+ ;
64
+ (locales ??= []).push({
65
+ lang: name,
66
+ label: name,
67
+ ...KNOWN_LOCALE_CONFIGS[name],
68
+ });
69
+ }
70
+ }
38
71
  return {
39
72
  userBase,
40
73
  root,
@@ -64,19 +97,7 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
64
97
  enableScrollToTop: true,
65
98
  // https://github.com/web-infra-dev/rspress/issues/2011
66
99
  outline: true,
67
- ...(fallbackToZh
68
- ? zhLocaleConfig
69
- : {
70
- locales: [
71
- { lang: 'en', label: 'English' },
72
- { lang: 'zh', label: '简体中文', ...zhLocaleConfig },
73
- (await pathExists(path.resolve(root, 'ru'), 'directory')) && {
74
- lang: 'ru',
75
- label: 'Русский',
76
- ...ruLocaleConfig,
77
- },
78
- ].filter(Boolean),
79
- }),
100
+ ...(fallbackToZh ? KNOWN_LOCALE_CONFIGS.zh : { locales }),
80
101
  },
81
102
  plugins: [
82
103
  apiPlugin({
@@ -144,24 +165,28 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
144
165
  },
145
166
  };
146
167
  };
147
- const findConfig = (basePath) => {
148
- return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
168
+ const findConfig = async (basePath) => {
169
+ for (const configFile of DEFAULT_EXTENSIONS.map((ext) => basePath + ext)) {
170
+ if (await pathExists(configFile, 'file')) {
171
+ return configFile;
172
+ }
173
+ }
149
174
  };
150
- export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, } = {}) {
175
+ export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, includeLanguage: includeLanguages, excludeLanguage: excludeLanguages, } = {}) {
151
176
  let configFilePath;
152
177
  if (configFile) {
153
178
  configFilePath = path.resolve(configFile);
154
179
  }
155
180
  else {
156
181
  if (root) {
157
- configFilePath = findConfig(path.resolve(root, DEFAULT_CONFIG_NAME));
182
+ configFilePath = await findConfig(path.resolve(root, DEFAULT_CONFIG_NAME));
158
183
  }
159
184
  if (!configFilePath) {
160
- configFilePath = findConfig(path.resolve(DEFAULT_CONFIG_NAME));
185
+ configFilePath = await findConfig(path.resolve(DEFAULT_CONFIG_NAME));
161
186
  }
162
187
  // when root is not specified, try to find config in docs folder
163
188
  if (!root && !configFilePath) {
164
- configFilePath = findConfig(path.resolve('docs', DEFAULT_CONFIG_NAME));
189
+ configFilePath = await findConfig(path.resolve('docs', DEFAULT_CONFIG_NAME));
165
190
  }
166
191
  }
167
192
  let config;
@@ -192,7 +217,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
192
217
  }
193
218
  else {
194
219
  const sitesConfigFilePath = path.resolve(SITES_FILE);
195
- if (fs.existsSync(sitesConfigFilePath)) {
220
+ if (await pathExists(sitesConfigFilePath, 'file')) {
196
221
  config.sites = await resolveStaticConfig(sitesConfigFilePath);
197
222
  }
198
223
  }
@@ -209,6 +234,8 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
209
234
  force,
210
235
  open,
211
236
  lazy,
237
+ includeLanguages,
238
+ excludeLanguages,
212
239
  });
213
240
  base = commonConfig.base;
214
241
  const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
@@ -230,10 +257,10 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
230
257
  }
231
258
  if (ensureDefaultLogo) {
232
259
  const publicPath = path.resolve(mergedConfig.root, `public`);
233
- fs.mkdirSync(publicPath, { recursive: true });
260
+ await fs.mkdir(publicPath, { recursive: true });
234
261
  const logoPath = path.resolve(publicPath, removeLeadingSlash(DEFAULT_LOGO));
235
- if (!fs.existsSync(logoPath)) {
236
- fs.copyFileSync(pkgResolve(`assets${DEFAULT_LOGO}`), logoPath);
262
+ if (!(await pathExists(logoPath))) {
263
+ await fs.copyFile(pkgResolve(`assets${DEFAULT_LOGO}`), logoPath);
237
264
  }
238
265
  }
239
266
  if (mergedConfig.i18nSourcePath) {
package/lib/types.d.ts CHANGED
@@ -14,6 +14,8 @@ export interface GlobalCliOptions {
14
14
  force?: boolean;
15
15
  open?: boolean;
16
16
  lazy?: boolean;
17
+ includeLanguage?: string[];
18
+ excludeLanguage?: string[];
17
19
  }
18
20
  export interface TranslateOptions {
19
21
  systemPrompt?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.19.6",
3
+ "version": "0.20.1",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
@@ -43,10 +43,10 @@
43
43
  "dependencies": {
44
44
  "@inquirer/prompts": "^7.4.1",
45
45
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
46
- "@playwright/browser-chromium": "^1.51.1",
46
+ "@playwright/browser-chromium": "^1.52.0",
47
47
  "@rsbuild/plugin-yaml": "^1.0.2",
48
48
  "@rspress/core": "1.43.11",
49
- "@shikijs/transformers": "^3.2.2",
49
+ "@shikijs/transformers": "^3.3.0",
50
50
  "chokidar": "^4.0.3",
51
51
  "cli-progress": "^3.12.0",
52
52
  "clsx": "^2.1.1",
@@ -61,23 +61,23 @@
61
61
  "pdf-lib": "^1.17.1",
62
62
  "pdf-merger-js": "^5.1.2",
63
63
  "picomatch": "^4.0.2",
64
- "playwright": "^1.51.1",
64
+ "playwright": "^1.52.0",
65
65
  "react-markdown": "^8.0.7",
66
66
  "rehype-raw": "^6.1.1",
67
67
  "remark-directive": "^2.0.1",
68
68
  "remark-frontmatter": "^4.0.1",
69
69
  "remark-gfm": "^3.0.1",
70
- "shiki": "^3.2.2",
70
+ "shiki": "^3.3.0",
71
71
  "simple-git": "^3.27.0",
72
72
  "swagger2openapi": "^7.0.8",
73
- "tinyglobby": "^0.2.12",
73
+ "tinyglobby": "^0.2.13",
74
74
  "type-fest": "^4.40.0",
75
75
  "x-fetch": "^0.2.6",
76
76
  "yaml": "^2.7.1",
77
77
  "yoctocolors": "^2.1.1"
78
78
  },
79
79
  "devDependencies": {
80
- "@eslint/js": "^9.24.0",
80
+ "@eslint/js": "^9.25.1",
81
81
  "@swc-node/register": "^1.10.10",
82
82
  "@swc/core": "1.11.21",
83
83
  "@total-typescript/ts-reset": "^0.6.1",
@@ -89,19 +89,20 @@
89
89
  "@types/react-dom": "^18.3.6",
90
90
  "@types/swagger2openapi": "^7.0.4",
91
91
  "@unts/patch-package": "^8.1.1",
92
- "eslint": "^9.24.0",
93
- "eslint-import-resolver-typescript": "^4.3.2",
94
- "eslint-plugin-import-x": "^4.10.5",
92
+ "eslint": "^9.25.1",
93
+ "eslint-import-resolver-typescript": "^4.3.4",
94
+ "eslint-plugin-import-x": "^4.10.6",
95
95
  "nano-staged": "^0.8.0",
96
96
  "npm-run-all2": "^7.0.2",
97
97
  "prettier": "^3.5.3",
98
98
  "prettier-plugin-pkg": "^0.19.0",
99
99
  "simple-git-hooks": "^2.12.1",
100
100
  "typescript": "^5.8.3",
101
- "typescript-eslint": "^8.30.1",
102
- "yarn-berry-deduplicate": "^6.1.1"
101
+ "typescript-eslint": "^8.31.0",
102
+ "yarn-berry-deduplicate": "^6.1.3"
103
103
  },
104
104
  "publishConfig": {
105
- "access": "public"
105
+ "access": "public",
106
+ "registry": "https://registry.npmjs.org"
106
107
  }
107
108
  }
@@ -1,13 +0,0 @@
1
- export interface QuickNavItem {
2
- icon: string;
3
- title: string;
4
- links: Array<{
5
- title: string;
6
- href: string;
7
- }>;
8
- }
9
- export interface QuickNavProps {
10
- items: QuickNavItem[];
11
- }
12
- export declare const QuickNav: ({ items }: QuickNavProps) => import("react/jsx-runtime").JSX.Element;
13
- export default QuickNav;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { normalizeImagePath } from '@rspress/core/runtime';
3
- import { Link } from '@rspress/core/theme';
4
- import classes from '../../../styles/quick-nav.module.scss';
5
- export const QuickNav = ({ items }) => {
6
- return (_jsx("ul", { className: classes.container, children: items.map((item, index) => (_jsxs("li", { className: classes.item, children: [_jsxs("div", { className: classes.title, title: item.title, children: [_jsx("img", { src: normalizeImagePath(item.icon), alt: item.title }), item.title] }), _jsx("hr", { className: classes.divider }), _jsx("ul", { className: classes.links, children: item.links.map((link, index) => (_jsx("li", { children: _jsx(Link, { href: link.href, title: link.title, children: link.title }) }, index))) })] }, index))) }));
7
- };
8
- export default QuickNav;
@@ -1,32 +0,0 @@
1
- import type { serve } from '@rspress/core';
2
-
3
- import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, ReferenceItem, ReleaseNotesOptions } from '../plugins/index.js';
4
- import type { DoomSite } from '../shared/index.js';
5
-
6
- export type BaseServeOptions = Parameters<typeof serve>[0];
7
- export type ServeOptions = Omit<BaseServeOptions, 'config'>;
8
- export interface GlobalCliOptions {
9
- config?: string;
10
- base?: string;
11
- prefix?: string;
12
- v?: string;
13
- download?: boolean;
14
- ignore?: boolean;
15
- force?: boolean;
16
- }
17
- declare module '@rspress/shared' {
18
- interface UserConfig {
19
- userBase?: string;
20
- api?: Omit<ApiPluginOptions, 'localBasePath'>;
21
- sites?: DoomSite[];
22
- permission?: PermissionPluginOptions;
23
- reference?: ReferenceItem[];
24
- sidebar?: Omit<AutoSidebarPluginOptions, 'download' | 'excludeRoutes'>;
25
- releaseNotes?: ReleaseNotesOptions;
26
- internalRoutes?: string[];
27
- }
28
- }
29
- export type ContentProcessor = {
30
- type: 'ejsTemplate';
31
- data?: Record<string, unknown>;
32
- };
@@ -1 +0,0 @@
1
- export {};