@alauda/doom 0.21.0 → 0.22.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/translate.js +4 -4
- package/lib/global/VersionsNav/SvgWrapper.d.ts +3 -2
- package/lib/plugins/replace/resolve-release.js +57 -43
- package/lib/plugins/replace/types.d.ts +1 -0
- package/lib/runtime/components/Mermaid.d.ts +1 -2
- package/package.json +14 -14
- package/lib/runtime/components/QuickNav.d.ts +0 -13
- package/lib/runtime/components/QuickNav.js +0 -8
- package/lib/utils/types.d.ts +0 -32
- package/lib/utils/types.js +0 -1
package/lib/cli/translate.js
CHANGED
|
@@ -12,7 +12,7 @@ import matter from 'gray-matter';
|
|
|
12
12
|
import { AzureOpenAI, RateLimitError } from 'openai';
|
|
13
13
|
import { pRateLimit } from 'p-ratelimit';
|
|
14
14
|
import { glob } from 'tinyglobby';
|
|
15
|
-
import {
|
|
15
|
+
import { xfetch } from 'x-fetch';
|
|
16
16
|
import { parse } from 'yaml';
|
|
17
17
|
import { cyan, red } from 'yoctocolors';
|
|
18
18
|
import { mdProcessor, mdxProcessor, normalizeImgSrc, } from '../plugins/index.js';
|
|
@@ -62,7 +62,7 @@ const DEFAULT_SYSTEM_PROMPT = `
|
|
|
62
62
|
`.trim();
|
|
63
63
|
let openai;
|
|
64
64
|
const resolveTerms_ = async () => {
|
|
65
|
-
const terms = await
|
|
65
|
+
const terms = await xfetch('https://gitlab-ce.alauda.cn/alauda-public/product-doc-guide/-/raw/main/terms.yaml', { type: 'text' });
|
|
66
66
|
const parsedTerms = parse(terms);
|
|
67
67
|
return ('- 以下是常见的相关术语词汇对应表(English <-> 中文)\n' +
|
|
68
68
|
parsedTerms.map(({ en, zh = en }) => ` * ${en} <-> ${zh}`).join('\n'));
|
|
@@ -81,8 +81,8 @@ export const translate = async ({ source, sourceContent, target, targetContent =
|
|
|
81
81
|
if (!openai) {
|
|
82
82
|
openai = new AzureOpenAI({
|
|
83
83
|
endpoint: process.env.AZURE_OPENAI_ENDPOINT ||
|
|
84
|
-
'https://
|
|
85
|
-
apiKey: process.env.AZURE_OPENAI_API_KEY
|
|
84
|
+
'https://azure-ai-api-gateway.alauda.cn',
|
|
85
|
+
apiKey: process.env.AZURE_OPENAI_API_KEY,
|
|
86
86
|
apiVersion: process.env.OPENAI_API_VERSION || '2025-03-01-preview',
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { FC, SVGAttributes } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* A wrapper for custom SVG icon.
|
|
3
4
|
* When the user uses a custom SVG, the imported icon can be a string or a React component.
|
|
4
5
|
*/
|
|
5
6
|
export declare function SvgWrapper({ icon: Icon, ...rest }: {
|
|
6
|
-
icon: string |
|
|
7
|
-
} &
|
|
7
|
+
icon: string | FC<React.SVGProps<SVGSVGElement>>;
|
|
8
|
+
} & SVGAttributes<SVGSVGElement | HTMLImageElement>): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { logger } from '@rspress/shared/logger';
|
|
2
2
|
import { render } from 'ejs';
|
|
3
|
+
import { ResponseError, xfetch } from 'x-fetch';
|
|
3
4
|
import { cyan, red } from 'yoctocolors';
|
|
4
5
|
import { isCI } from './utils.js';
|
|
5
6
|
const releaseCache = new Map();
|
|
@@ -7,41 +8,38 @@ const FIELD_MAPPER = {
|
|
|
7
8
|
zh: 'customfield_13800',
|
|
8
9
|
en: 'customfield_13801',
|
|
9
10
|
};
|
|
11
|
+
const issuesToListItems = (issues, lang) => issues
|
|
12
|
+
.map((issue) => {
|
|
13
|
+
const description = ((FIELD_MAPPER[lang] && issue.fields[FIELD_MAPPER[lang]]) ||
|
|
14
|
+
issue.fields[FIELD_MAPPER.en])?.trim();
|
|
15
|
+
if (!description) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
type: 'listItem',
|
|
20
|
+
children: [
|
|
21
|
+
{
|
|
22
|
+
type: 'paragraph',
|
|
23
|
+
children: description
|
|
24
|
+
.split('\n')
|
|
25
|
+
.map((line) => ({ type: 'text', value: line }))
|
|
26
|
+
.reduce((acc, curr, index) => {
|
|
27
|
+
if (index === 0) {
|
|
28
|
+
return [curr];
|
|
29
|
+
}
|
|
30
|
+
return acc.concat({ type: 'html', value: '<br>' }, curr);
|
|
31
|
+
}, []),
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
})
|
|
36
|
+
.filter(Boolean);
|
|
10
37
|
const { JIRA_USERNAME, JIRA_PASSWORD } = process.env;
|
|
11
|
-
const issuesToMdast = (issues, lang) => {
|
|
12
|
-
return issues
|
|
13
|
-
.map((issue) => {
|
|
14
|
-
const description = ((lang !== 'en' && issue.fields[FIELD_MAPPER[lang]]) ||
|
|
15
|
-
issue.fields[FIELD_MAPPER.en])?.trim();
|
|
16
|
-
if (!description) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
type: 'listItem',
|
|
21
|
-
children: [
|
|
22
|
-
{
|
|
23
|
-
type: 'paragraph',
|
|
24
|
-
children: description
|
|
25
|
-
.split('\n')
|
|
26
|
-
.map((line) => {
|
|
27
|
-
return {
|
|
28
|
-
type: 'text',
|
|
29
|
-
value: line,
|
|
30
|
-
};
|
|
31
|
-
})
|
|
32
|
-
.reduce((acc, curr, index) => {
|
|
33
|
-
if (index === 0) {
|
|
34
|
-
return [curr];
|
|
35
|
-
}
|
|
36
|
-
return acc.concat({ type: 'html', value: '<br>' }, curr);
|
|
37
|
-
}, []),
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
})
|
|
42
|
-
.filter((_) => !!_);
|
|
43
|
-
};
|
|
44
38
|
let warned = false;
|
|
39
|
+
const NO_ISSUE_MAPPER = {
|
|
40
|
+
zh: '此次发版无相关问题。',
|
|
41
|
+
en: 'No issues in this release.',
|
|
42
|
+
};
|
|
45
43
|
const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
46
44
|
const query = new URLSearchParams(releaseQuery);
|
|
47
45
|
const templateName = query.get('template');
|
|
@@ -62,10 +60,8 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
62
60
|
if (warned) {
|
|
63
61
|
return;
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
const message = `${cyan('`JIRA_USERNAME`')} and ${cyan('`JIRA_PASSWORD`')} environments must be set for fetching Jira issues`;
|
|
63
|
+
warned = true;
|
|
64
|
+
const message = `\`${cyan('JIRA_USERNAME')}\` and \`${cyan('JIRA_PASSWORD')}\` environments must be set for fetching Jira issues`;
|
|
69
65
|
if (isCI) {
|
|
70
66
|
throw new Error(message);
|
|
71
67
|
}
|
|
@@ -81,14 +77,32 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
81
77
|
}
|
|
82
78
|
const jql = await render(template, data, { async: true });
|
|
83
79
|
logger.info(`Fetching release notes for query \`${cyan(releaseQuery)}\``);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
let issues;
|
|
81
|
+
try {
|
|
82
|
+
;
|
|
83
|
+
({ issues } = await xfetch(`https://jira.alauda.cn/rest/api/2/search?${new URLSearchParams({ jql })}`, { headers: { Authorization } }));
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (err instanceof ResponseError) {
|
|
87
|
+
logger.error(`Failed to fetch release notes for query \`${red(releaseQuery)}\` with status \`${err.response.status}\` and ${err.data ? `data ${JSON.stringify(data, null, 2)}` : `message \`${err.message}\``}`);
|
|
88
|
+
}
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
return ['en', 'zh'].reduce((acc, lang) => Object.assign(acc, {
|
|
92
|
+
[lang]: issues.length
|
|
93
|
+
? {
|
|
94
|
+
type: 'list',
|
|
95
|
+
children: issuesToListItems(issues, lang),
|
|
96
|
+
}
|
|
97
|
+
: {
|
|
98
|
+
type: 'paragraph',
|
|
99
|
+
children: [
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
value: NO_ISSUE_MAPPER[lang] || NO_ISSUE_MAPPER.en,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
92
106
|
}), {});
|
|
93
107
|
};
|
|
94
108
|
export const resolveRelease = async (releaseTemplates, releaseQuery, lang) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
1
|
export interface MermaidProps {
|
|
3
2
|
className?: string;
|
|
4
3
|
children: string;
|
|
5
4
|
}
|
|
6
|
-
export declare const Mermaid:
|
|
5
|
+
export declare const Mermaid: ({ className, children }: MermaidProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
6
|
export default Mermaid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
46
46
|
"@playwright/browser-chromium": "^1.52.0",
|
|
47
47
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
48
|
-
"@rspress/core": "1.43.
|
|
49
|
-
"@shikijs/transformers": "^3.
|
|
48
|
+
"@rspress/core": "1.43.12",
|
|
49
|
+
"@shikijs/transformers": "^3.4.0",
|
|
50
50
|
"chokidar": "^4.0.3",
|
|
51
51
|
"cli-progress": "^3.12.0",
|
|
52
52
|
"clsx": "^2.1.1",
|
|
53
53
|
"commander": "^13.1.0",
|
|
54
54
|
"ejs": "^3.1.10",
|
|
55
|
-
"es-toolkit": "^1.
|
|
55
|
+
"es-toolkit": "^1.37.2",
|
|
56
56
|
"html-tag-names": "^2.1.0",
|
|
57
57
|
"mermaid": "^11.6.0",
|
|
58
58
|
"openai": "^5.0.0-beta.0",
|
|
@@ -67,31 +67,31 @@
|
|
|
67
67
|
"remark-directive": "^2.0.1",
|
|
68
68
|
"remark-frontmatter": "^4.0.1",
|
|
69
69
|
"remark-gfm": "^3.0.1",
|
|
70
|
-
"shiki": "^3.
|
|
70
|
+
"shiki": "^3.4.0",
|
|
71
71
|
"simple-git": "^3.27.0",
|
|
72
72
|
"swagger2openapi": "^7.0.8",
|
|
73
73
|
"tinyglobby": "^0.2.13",
|
|
74
|
-
"type-fest": "^4.
|
|
74
|
+
"type-fest": "^4.41.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.
|
|
80
|
+
"@eslint/js": "^9.26.0",
|
|
81
81
|
"@swc-node/register": "^1.10.10",
|
|
82
|
-
"@swc/core": "1.11.
|
|
82
|
+
"@swc/core": "1.11.24",
|
|
83
83
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
84
84
|
"@types/cli-progress": "^3.11.6",
|
|
85
85
|
"@types/ejs": "^3.1.5",
|
|
86
|
-
"@types/node": "^18.19.
|
|
86
|
+
"@types/node": "^18.19.96",
|
|
87
87
|
"@types/picomatch": "^4.0.0",
|
|
88
|
-
"@types/react": "^18.3.
|
|
89
|
-
"@types/react-dom": "^18.3.
|
|
88
|
+
"@types/react": "^18.3.21",
|
|
89
|
+
"@types/react-dom": "^18.3.7",
|
|
90
90
|
"@types/swagger2openapi": "^7.0.4",
|
|
91
91
|
"@unts/patch-package": "^8.1.1",
|
|
92
|
-
"eslint": "^9.
|
|
92
|
+
"eslint": "^9.26.0",
|
|
93
93
|
"eslint-import-resolver-typescript": "^4.3.4",
|
|
94
|
-
"eslint-plugin-import-x": "^4.
|
|
94
|
+
"eslint-plugin-import-x": "^4.11.0",
|
|
95
95
|
"nano-staged": "^0.8.0",
|
|
96
96
|
"npm-run-all2": "^7.0.2",
|
|
97
97
|
"prettier": "^3.5.3",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"prettier-plugin-properties": "^0.3.0",
|
|
100
100
|
"simple-git-hooks": "^2.13.0",
|
|
101
101
|
"typescript": "^5.8.3",
|
|
102
|
-
"typescript-eslint": "^8.
|
|
102
|
+
"typescript-eslint": "^8.32.0",
|
|
103
103
|
"yarn-berry-deduplicate": "^6.1.3"
|
|
104
104
|
},
|
|
105
105
|
"publishConfig": {
|
|
@@ -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;
|
package/lib/utils/types.d.ts
DELETED
|
@@ -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
|
-
};
|
package/lib/utils/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|