@alauda/doom 0.7.3 → 0.8.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/load-config.js +6 -2
- package/lib/plugins/api/index.d.ts +1 -1
- package/lib/plugins/api/index.js +10 -15
- package/lib/plugins/api/types.d.ts +1 -0
- package/lib/plugins/replace/remark-replace.js +2 -4
- package/lib/plugins/replace/resolve-release.js +16 -6
- package/lib/plugins/replace/utils.d.ts +1 -0
- package/lib/plugins/replace/utils.js +2 -0
- package/lib/runtime/components/AcpApisOverview.d.ts +2 -0
- package/lib/runtime/components/AcpApisOverview.js +4 -0
- package/lib/runtime/components/Callouts.js +1 -1
- package/lib/runtime/components/ExternalApisOverview.d.ts +3 -0
- package/lib/runtime/components/ExternalApisOverview.js +4 -0
- package/lib/runtime/components/ExternalSite.d.ts +2 -5
- package/lib/runtime/components/ExternalSite.js +2 -27
- package/lib/runtime/components/ExternalSiteLink.js +5 -2
- package/lib/runtime/components/_ExternalSiteBase.d.ts +11 -0
- package/lib/runtime/components/_ExternalSiteBase.js +36 -0
- package/lib/runtime/components/index.d.ts +2 -0
- package/lib/runtime/components/index.js +2 -0
- package/package.json +1 -1
package/lib/cli/load-config.js
CHANGED
|
@@ -22,6 +22,7 @@ const zhLocaleConfig = {
|
|
|
22
22
|
const getCommonConfig = (config, cliRoot, configFilePath, version, force) => {
|
|
23
23
|
const fallbackToZh = 'lang' in config && config.lang == null;
|
|
24
24
|
const root = resolveDocRoot(CWD, cliRoot, config.root);
|
|
25
|
+
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
25
26
|
return {
|
|
26
27
|
root,
|
|
27
28
|
lang: fallbackToZh ? 'zh' : config.lang,
|
|
@@ -56,7 +57,10 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, force) => {
|
|
|
56
57
|
}),
|
|
57
58
|
},
|
|
58
59
|
plugins: [
|
|
59
|
-
apiPlugin(
|
|
60
|
+
apiPlugin({
|
|
61
|
+
...config.api,
|
|
62
|
+
localBasePath,
|
|
63
|
+
}),
|
|
60
64
|
autoSidebarPlugin(config.sidebar),
|
|
61
65
|
globalPlugin({
|
|
62
66
|
sites: config.sites,
|
|
@@ -65,7 +69,7 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, force) => {
|
|
|
65
69
|
replacePlugin({
|
|
66
70
|
root,
|
|
67
71
|
lang: fallbackToZh ? null : (config.lang ?? 'en'),
|
|
68
|
-
localBasePath
|
|
72
|
+
localBasePath,
|
|
69
73
|
items: config.reference,
|
|
70
74
|
force,
|
|
71
75
|
releaseNotes: config.releaseNotes,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
2
|
import type { ApiPluginOptions } from './types.js';
|
|
3
|
-
export declare const apiPlugin: ({ crds, openapis, references, pathPrefix, }
|
|
3
|
+
export declare const apiPlugin: ({ localBasePath, crds, openapis, references, pathPrefix, }: ApiPluginOptions) => RspressPlugin;
|
package/lib/plugins/api/index.js
CHANGED
|
@@ -3,25 +3,24 @@ import { openapiSchemaToJsonSchema } from '@openapi-contrib/openapi-schema-to-js
|
|
|
3
3
|
import { convertObj } from 'swagger2openapi';
|
|
4
4
|
import { glob } from 'tinyglobby';
|
|
5
5
|
import { resolveStaticConfig } from '../../utils/index.js';
|
|
6
|
-
export const apiPlugin = ({ crds, openapis, references, pathPrefix, }
|
|
7
|
-
const crdsMap = {};
|
|
8
|
-
const openapisMap = {};
|
|
9
|
-
const shared = {};
|
|
6
|
+
export const apiPlugin = ({ localBasePath, crds, openapis, references, pathPrefix, }) => {
|
|
10
7
|
return {
|
|
11
8
|
name: 'doom-api',
|
|
12
|
-
async
|
|
9
|
+
async extendPageData(pageData) {
|
|
10
|
+
const crdsMap = {};
|
|
11
|
+
const openapisMap = {};
|
|
13
12
|
if (crds) {
|
|
14
13
|
for (const file of await glob(crds, {
|
|
15
|
-
cwd:
|
|
14
|
+
cwd: localBasePath,
|
|
16
15
|
})) {
|
|
17
|
-
crdsMap[file] = await resolveStaticConfig(path.resolve(
|
|
16
|
+
crdsMap[file] = await resolveStaticConfig(path.resolve(localBasePath, file));
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
if (openapis) {
|
|
21
20
|
for (const file of await glob(openapis, {
|
|
22
|
-
cwd:
|
|
21
|
+
cwd: localBasePath,
|
|
23
22
|
})) {
|
|
24
|
-
let doc = await resolveStaticConfig(path.resolve(
|
|
23
|
+
let doc = await resolveStaticConfig(path.resolve(localBasePath, file));
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
26
25
|
doc.info ??= { title: 'Unknown', version: '0.0.0' };
|
|
27
26
|
if ('swagger' in doc && doc.swagger === '2.0') {
|
|
@@ -34,14 +33,10 @@ export const apiPlugin = ({ crds, openapis, references, pathPrefix, } = {}) => {
|
|
|
34
33
|
openapisMap[file] = doc;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
shared.references = references;
|
|
38
|
-
shared.pathPrefix = pathPrefix;
|
|
39
|
-
},
|
|
40
|
-
extendPageData(pageData) {
|
|
41
36
|
pageData.crdsMap = crdsMap;
|
|
42
37
|
pageData.openapisMap = openapisMap;
|
|
43
|
-
pageData.references =
|
|
44
|
-
pageData.pathPrefix =
|
|
38
|
+
pageData.references = references;
|
|
39
|
+
pageData.pathPrefix = pathPrefix;
|
|
45
40
|
},
|
|
46
41
|
};
|
|
47
42
|
};
|
|
@@ -5,7 +5,7 @@ import { logger } from '@rspress/shared/logger';
|
|
|
5
5
|
import { parse, stringify } from 'yaml';
|
|
6
6
|
import { cyan, red } from 'yoctocolors';
|
|
7
7
|
import { normalizeImgSrc } from './normalize-img-src.js';
|
|
8
|
-
import { getFrontmatterNode, mdProcessor, mdxProcessor } from './utils.js';
|
|
8
|
+
import { getFrontmatterNode, isCI, mdProcessor, mdxProcessor } from './utils.js';
|
|
9
9
|
import { resolveReference } from './resolve-reference.js';
|
|
10
10
|
import { resolveRelease } from './resolve-release.js';
|
|
11
11
|
const MD_REF_START_COMMENT_PATTERN = /<!-{2,} *reference-start#(.+) *-{2,}>/;
|
|
@@ -24,8 +24,6 @@ export const maybeHaveRef = (filepath, content) => {
|
|
|
24
24
|
? [MDX_REF_START_COMMENT_PATTERN, MDX_RELEASE_COMMENT_PATTERN]
|
|
25
25
|
: [MD_REF_START_COMMENT_PATTERN, MD_RELEASE_COMMENT_PATTERN]).some((p) => p.test(content));
|
|
26
26
|
};
|
|
27
|
-
const { CI } = process.env;
|
|
28
|
-
const isCi = CI !== 'false' && !!CI;
|
|
29
27
|
export const remarkReplace = function ({ lang, localBasePath, root, items, force, releaseNotes }) {
|
|
30
28
|
return async (ast, vfile) => {
|
|
31
29
|
const filepath = vfile.path;
|
|
@@ -145,7 +143,7 @@ export const remarkReplace = function ({ lang, localBasePath, root, items, force
|
|
|
145
143
|
await fs.writeFile(filepath, newContent);
|
|
146
144
|
if (!vfile.data.original && isProduction()) {
|
|
147
145
|
const message = `Reference block in \`${cyan(relativePath)}\` has been updated, please commit the changes`;
|
|
148
|
-
if (
|
|
146
|
+
if (isCI) {
|
|
149
147
|
process.env.__DOOM_REBUILD__ = 'true';
|
|
150
148
|
}
|
|
151
149
|
logger.warn(message);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { logger } from '@rspress/shared/logger';
|
|
2
2
|
import { render } from 'ejs';
|
|
3
3
|
import { cyan, red } from 'yoctocolors';
|
|
4
|
+
import { isCI } from './utils.js';
|
|
4
5
|
const releaseCache = new Map();
|
|
5
6
|
const FIELD_MAPPER = {
|
|
6
7
|
zh: 'customfield_13800',
|
|
7
8
|
en: 'customfield_13801',
|
|
8
9
|
};
|
|
9
|
-
const {
|
|
10
|
+
const { JIRA_USERNAME, JIRA_PASSWORD } = process.env;
|
|
10
11
|
const issuesToMdast = (issues, lang) => {
|
|
11
12
|
return issues
|
|
12
13
|
.map((issue) => {
|
|
@@ -40,6 +41,7 @@ const issuesToMdast = (issues, lang) => {
|
|
|
40
41
|
})
|
|
41
42
|
.filter((_) => !!_);
|
|
42
43
|
};
|
|
44
|
+
let warned = false;
|
|
43
45
|
const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
44
46
|
const query = new URLSearchParams(releaseQuery);
|
|
45
47
|
const templateName = query.get('template');
|
|
@@ -53,14 +55,22 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
57
|
let Authorization;
|
|
56
|
-
if (
|
|
57
|
-
Authorization = `Bearer ${JIRA_TOKEN}`;
|
|
58
|
-
}
|
|
59
|
-
else if (JIRA_USERNAME && JIRA_PASSWORD) {
|
|
58
|
+
if (JIRA_USERNAME && JIRA_PASSWORD) {
|
|
60
59
|
Authorization = `Basic ${Buffer.from(`${JIRA_USERNAME}:${JIRA_PASSWORD}`).toString('base64')}`;
|
|
61
60
|
}
|
|
62
61
|
else {
|
|
63
|
-
|
|
62
|
+
if (warned) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
warned = true;
|
|
67
|
+
}
|
|
68
|
+
const message = `${cyan('`JIRA_USERNAME`')} and ${cyan('`JIRA_PASSWORD`')} environments must be set for fetching Jira issues`;
|
|
69
|
+
if (isCI) {
|
|
70
|
+
throw new Error(message);
|
|
71
|
+
}
|
|
72
|
+
logger.warn(message);
|
|
73
|
+
return;
|
|
64
74
|
}
|
|
65
75
|
const data = {};
|
|
66
76
|
for (const [key, value] of query.entries()) {
|
|
@@ -12,3 +12,4 @@ export declare const stringifySettings: Options;
|
|
|
12
12
|
export declare const mdProcessor: import("unified").FrozenProcessor<Root, Root, Root, string>;
|
|
13
13
|
export declare const mdxProcessor: import("unified").FrozenProcessor<Root, Root, Root, string>;
|
|
14
14
|
export declare const getFrontmatterNode: (ast: Root) => YAML | undefined;
|
|
15
|
+
export declare const isCI: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const Callouts = ({ children }) => {
|
|
3
|
-
return _jsx("
|
|
3
|
+
return _jsx("div", { className: "my-4 leading-7 doom-callouts", children: children });
|
|
4
4
|
};
|
|
5
5
|
export default Callouts;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
1
2
|
export interface ExternalSiteProps {
|
|
2
3
|
name: string;
|
|
3
4
|
}
|
|
4
|
-
export
|
|
5
|
-
name: string;
|
|
6
|
-
displayName: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const ExternalSite: ({ name }: ExternalSiteProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const ExternalSite: FC<ExternalSiteProps>;
|
|
9
6
|
export default ExternalSite;
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
import { handleCJKWhitespaces } from '../utils.js';
|
|
5
|
-
import { Directive } from './Directive.js';
|
|
6
|
-
import { ExternalSiteLink } from './ExternalSiteLink.js';
|
|
7
|
-
const Notes = {
|
|
8
|
-
en({ name, displayName }) {
|
|
9
|
-
return (_jsxs(_Fragment, { children: ["Because ", displayName, " releases on a different cadence from Alauda Container Platform, the ", displayName, " documentation is now available as a separate documentation set at", ' ', _jsx(ExternalSiteLink, { name: name, children: displayName }), "."] }));
|
|
10
|
-
},
|
|
11
|
-
zh({ name, displayName }) {
|
|
12
|
-
const displayName_ = handleCJKWhitespaces(displayName);
|
|
13
|
-
return (_jsxs(_Fragment, { children: ["\u56E0\u4E3A", displayName_, "\u7684\u53D1\u7248\u5468\u671F\u4E0E\u7075\u96C0\u4E91\u5BB9\u5668\u5E73\u53F0\u4E0D\u540C\uFF0C\u6240\u4EE5", displayName_, "\u7684\u6587\u6863\u73B0\u5728\u4F5C\u4E3A\u72EC\u7ACB\u7684\u6587\u6863\u7AD9\u70B9\u6258\u7BA1\u5728", displayName_.startsWith(' ') ? ' ' : '', _jsx(ExternalSiteLink, { name: name, children: displayName }), "\u3002"] }));
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
export const ExternalSite = ({ name }) => {
|
|
17
|
-
const { siteData, page } = usePageData();
|
|
18
|
-
const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
|
|
19
|
-
const fallbackLang = siteData.lang || 'zh';
|
|
20
|
-
const lang = useLang() || fallbackLang;
|
|
21
|
-
const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.[fallbackLang] || name, []);
|
|
22
|
-
if (!site) {
|
|
23
|
-
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
24
|
-
}
|
|
25
|
-
const Note = Notes[lang] || Notes[fallbackLang] || Notes.en;
|
|
26
|
-
return (_jsx(Directive, { title: "Note", children: _jsx(Note, { name: name, displayName: displayName }) }));
|
|
27
|
-
};
|
|
1
|
+
import { ExternalSiteBase } from './_ExternalSiteBase.js';
|
|
2
|
+
export const ExternalSite = ExternalSiteBase;
|
|
28
3
|
export default ExternalSite;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { usePageData } from '@rspress/core/runtime';
|
|
2
|
+
import { useLang, usePageData } from '@rspress/core/runtime';
|
|
3
3
|
import { addTrailingSlash, isExternalUrl, removeLeadingSlash, } from '@rspress/shared';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useMemo } from 'react';
|
|
@@ -9,6 +9,7 @@ import classes from '../../../styles/link.module.scss';
|
|
|
9
9
|
export const ExternalSiteLink = ({ name, href = '', className, ...props }) => {
|
|
10
10
|
const { page } = usePageData();
|
|
11
11
|
const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
|
|
12
|
+
const lang = useLang();
|
|
12
13
|
if (!site) {
|
|
13
14
|
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
14
15
|
}
|
|
@@ -18,6 +19,8 @@ export const ExternalSiteLink = ({ name, href = '', className, ...props }) => {
|
|
|
18
19
|
const siteBase = addTrailingSlash(site.base);
|
|
19
20
|
return (_jsx("a", { href: (page.v
|
|
20
21
|
? addTrailingSlash(siteBase + normalizeVersion(site.version))
|
|
21
|
-
: siteBase) +
|
|
22
|
+
: siteBase) +
|
|
23
|
+
(lang ? `${lang}/` : '') +
|
|
24
|
+
removeLeadingSlash(href), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'cursor-pointer', className), ...props }));
|
|
22
25
|
};
|
|
23
26
|
export default ExternalSiteLink;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface ExternalSiteBaseProps {
|
|
3
|
+
name: string;
|
|
4
|
+
template?: 'apisOverview';
|
|
5
|
+
}
|
|
6
|
+
export interface ExternalSiteNoteProps {
|
|
7
|
+
name: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export type Notes = Partial<Record<string, FC<ExternalSiteNoteProps>>>;
|
|
11
|
+
export declare const ExternalSiteBase: ({ name, template }: ExternalSiteBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLang, usePageData } from '@rspress/core/runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { handleCJKWhitespaces } from '../utils.js';
|
|
5
|
+
import Directive from './Directive.js';
|
|
6
|
+
import ExternalSiteLink from './ExternalSiteLink.js';
|
|
7
|
+
const SiteNotes = {
|
|
8
|
+
en({ name, displayName }) {
|
|
9
|
+
return (_jsxs(_Fragment, { children: ["Because ", displayName, " releases on a different cadence from Alauda Container Platform, the ", displayName, " documentation is now available as a separate documentation set at", ' ', _jsx(ExternalSiteLink, { name: name, children: displayName }), "."] }));
|
|
10
|
+
},
|
|
11
|
+
zh({ name, displayName }) {
|
|
12
|
+
const displayName_ = handleCJKWhitespaces(displayName);
|
|
13
|
+
return (_jsxs(_Fragment, { children: ["\u56E0\u4E3A", displayName_, "\u7684\u53D1\u7248\u5468\u671F\u4E0E\u7075\u96C0\u4E91\u5BB9\u5668\u5E73\u53F0\u4E0D\u540C\uFF0C\u6240\u4EE5", displayName_, "\u7684\u6587\u6863\u73B0\u5728\u4F5C\u4E3A\u72EC\u7ACB\u7684\u6587\u6863\u7AD9\u70B9\u6258\u7BA1\u5728", displayName_.startsWith(' ') ? ' ' : '', _jsx(ExternalSiteLink, { name: name, children: displayName }), "\u3002"] }));
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const ApisOverviewNotes = {
|
|
17
|
+
en({ name, displayName }) {
|
|
18
|
+
return (_jsxs(_Fragment, { children: ["For the introduction to the usage methods of ", displayName, " APIs, please refer to", ' ', _jsxs(ExternalSiteLink, { name: name, href: "apis/overview/", children: [displayName, " APIs Guide"] }), "."] }));
|
|
19
|
+
},
|
|
20
|
+
zh({ name, displayName }) {
|
|
21
|
+
const displayName_ = handleCJKWhitespaces(displayName);
|
|
22
|
+
return (_jsxs(_Fragment, { children: ["\u5173\u4E8E", displayName_, " APIs \u7684\u4F7F\u7528\u65B9\u6CD5\u4ECB\u7ECD\u8BF7\u53C2\u8003", displayName_.startsWith(' ') ? ' ' : '', _jsxs(ExternalSiteLink, { name: name, href: "apis/overview/", children: [displayName, " APIs \u6307\u5357"] }), "\u3002"] }));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const ExternalSiteBase = ({ name, template }) => {
|
|
26
|
+
const { siteData, page } = usePageData();
|
|
27
|
+
const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
|
|
28
|
+
const lang = useLang() || siteData.lang || 'zh';
|
|
29
|
+
const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.en || name.toUpperCase(), []);
|
|
30
|
+
if (!site) {
|
|
31
|
+
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
32
|
+
}
|
|
33
|
+
const Notes = template === 'apisOverview' ? ApisOverviewNotes : SiteNotes;
|
|
34
|
+
const Note = Notes[lang] || Notes.en;
|
|
35
|
+
return (_jsx(Directive, { title: "Note", children: _jsx(Note, { name: name, displayName: displayName }) }));
|
|
36
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from './AcpApisOverview.js';
|
|
1
2
|
export * from './Badge.js';
|
|
2
3
|
export * from './Callouts.js';
|
|
3
4
|
export * from './Card.js';
|
|
4
5
|
export * from './Directive.js';
|
|
6
|
+
export * from './ExternalApisOverview.js';
|
|
5
7
|
export * from './ExternalSite.js';
|
|
6
8
|
export * from './ExternalSiteLink.js';
|
|
7
9
|
export * from './JsonViewer.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from './AcpApisOverview.js';
|
|
1
2
|
export * from './Badge.js';
|
|
2
3
|
export * from './Callouts.js';
|
|
3
4
|
export * from './Card.js';
|
|
4
5
|
export * from './Directive.js';
|
|
6
|
+
export * from './ExternalApisOverview.js';
|
|
5
7
|
export * from './ExternalSite.js';
|
|
6
8
|
export * from './ExternalSiteLink.js';
|
|
7
9
|
export * from './JsonViewer.js';
|