@alauda/doom 0.17.5 → 0.18.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.
- package/lib/cli/export.js +6 -3
- package/lib/cli/load-config.js +1 -5
- package/lib/cli/new.js +5 -2
- package/lib/cli/translate.d.ts +1 -1
- package/lib/cli/translate.js +4 -2
- package/lib/plugins/auto-sidebar/index.d.ts +3 -2
- package/lib/plugins/auto-sidebar/index.js +14 -5
- package/lib/shared/constants.d.ts +1 -0
- package/lib/shared/constants.js +8 -1
- package/lib/types.d.ts +1 -0
- package/package.json +15 -14
package/lib/cli/export.js
CHANGED
|
@@ -8,7 +8,7 @@ import { pathExists, setNodeEnv } from '../utils/index.js';
|
|
|
8
8
|
import { generatePdf, } from './export-pdf-core/index.js';
|
|
9
9
|
import { loadConfig } from './load-config.js';
|
|
10
10
|
export const exportCommand = new Command('export')
|
|
11
|
-
.description('Export the documentation as PDF')
|
|
11
|
+
.description('Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically')
|
|
12
12
|
.argument('[root]', 'Root directory of the documentation')
|
|
13
13
|
.option('-H, --host [host]', 'Serve host name')
|
|
14
14
|
.option('-P, --port [port]', 'Serve port number', '4173')
|
|
@@ -22,10 +22,12 @@ export const exportCommand = new Command('export')
|
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
config = await autoSidebar(config, {
|
|
25
|
-
|
|
25
|
+
ignore: globalOptions.ignore,
|
|
26
|
+
export: true,
|
|
26
27
|
});
|
|
27
28
|
config.builderConfig.server.open = false;
|
|
28
|
-
|
|
29
|
+
// make sure it won't be overridden by `serve`
|
|
30
|
+
const themeConfig = { ...config.themeConfig };
|
|
29
31
|
logger.start('Serving...');
|
|
30
32
|
await serve({ config, host, port });
|
|
31
33
|
const collectPages = (sidebarItems) => {
|
|
@@ -80,6 +82,7 @@ export const exportCommand = new Command('export')
|
|
|
80
82
|
},
|
|
81
83
|
};
|
|
82
84
|
const exportPdf = async (sidebarItems, lang = config.lang) => {
|
|
85
|
+
// console.log(sidebarItems, collectPages(sidebarItems))
|
|
83
86
|
await generatePdf({
|
|
84
87
|
pages: collectPages(sidebarItems),
|
|
85
88
|
outFile: getPdfName(lang, config.userBase, config.title),
|
package/lib/cli/load-config.js
CHANGED
|
@@ -23,7 +23,6 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
23
23
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
24
24
|
root = resolveDocRoot(CWD, root, config.root);
|
|
25
25
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
26
|
-
const excludeRoutes = (ignore && config.internalRoutes) || [];
|
|
27
26
|
const userBase = (base = addLeadingSlash(addTrailingSlash(base || config.base || '/')));
|
|
28
27
|
if (version && version !== 'unversioned') {
|
|
29
28
|
base = userBase + `${version}/`;
|
|
@@ -42,7 +41,6 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
42
41
|
'doom.config.*',
|
|
43
42
|
'**/assets/**/*',
|
|
44
43
|
'**/*.d.ts',
|
|
45
|
-
...excludeRoutes,
|
|
46
44
|
],
|
|
47
45
|
},
|
|
48
46
|
markdown: {
|
|
@@ -71,9 +69,7 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
71
69
|
apiPlugin({
|
|
72
70
|
localBasePath,
|
|
73
71
|
}),
|
|
74
|
-
autoSidebarPlugin({
|
|
75
|
-
excludeRoutes,
|
|
76
|
-
}),
|
|
72
|
+
autoSidebarPlugin({ ignore }),
|
|
77
73
|
directivesPlugin(),
|
|
78
74
|
globalPlugin({ version, download }),
|
|
79
75
|
mermaidPlugin(),
|
package/lib/cli/new.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Command } from 'commander';
|
|
|
6
6
|
import { render } from 'ejs';
|
|
7
7
|
import { glob } from 'tinyglobby';
|
|
8
8
|
import { cyan, magenta } from 'yoctocolors';
|
|
9
|
+
import { JS_STR_FALSY_VALUES } from '../shared/index.js';
|
|
9
10
|
import { resolveRepo, resolveStaticConfig } from '../utils/index.js';
|
|
10
11
|
export const DEFAULT_PATH = 'templates/scaffolding.yaml';
|
|
11
12
|
const scaffoldingTemplates = {
|
|
@@ -97,14 +98,16 @@ export const newCommand = new Command('new')
|
|
|
97
98
|
}
|
|
98
99
|
const parameters = {};
|
|
99
100
|
for (const param of scaffolding.parameters || []) {
|
|
100
|
-
parameters[param.name] =
|
|
101
|
+
parameters[param.name] =
|
|
102
|
+
await // @ts-expect-error -- no idea how to fix this
|
|
103
|
+
prompts[param.type](param.options);
|
|
101
104
|
}
|
|
102
105
|
logger.start('Generating scaffolding...');
|
|
103
106
|
for (const layout of scaffolding.layout || []) {
|
|
104
107
|
const source = path.resolve(base, render(layout.source, { parameters }));
|
|
105
108
|
const target = path.resolve(render(layout.target, { parameters }));
|
|
106
109
|
const when = layout.when && render(layout.when, { parameters });
|
|
107
|
-
if (
|
|
110
|
+
if (JS_STR_FALSY_VALUES.has(when)) {
|
|
108
111
|
continue;
|
|
109
112
|
}
|
|
110
113
|
switch (layout.type) {
|
package/lib/cli/translate.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface InternalTranslateOptions extends TranslateOptions {
|
|
|
16
16
|
targetContent?: string;
|
|
17
17
|
additionalPrompts?: string;
|
|
18
18
|
}
|
|
19
|
-
export declare const translate: ({ source, sourceContent, target, targetContent, systemPrompt, additionalPrompts, }: InternalTranslateOptions) => Promise<string>;
|
|
19
|
+
export declare const translate: ({ source, sourceContent, target, targetContent, systemPrompt, userPrompt, additionalPrompts, }: InternalTranslateOptions) => Promise<string>;
|
|
20
20
|
export interface TranslateCommandOptions {
|
|
21
21
|
source: string;
|
|
22
22
|
target: string;
|
package/lib/cli/translate.js
CHANGED
|
@@ -59,10 +59,12 @@ const DEFAULT_SYSTEM_PROMPT = `
|
|
|
59
59
|
|
|
60
60
|
最终只需要输出最后一步的结果,不需要输出之前步骤的结果。
|
|
61
61
|
|
|
62
|
+
<%= userPrompt %>
|
|
63
|
+
|
|
62
64
|
<%= additionalPrompts %>
|
|
63
65
|
`.trim();
|
|
64
66
|
let openai;
|
|
65
|
-
export const translate = async ({ source, sourceContent, target, targetContent = '', systemPrompt, additionalPrompts = '', }) => {
|
|
67
|
+
export const translate = async ({ source, sourceContent, target, targetContent = '', systemPrompt, userPrompt = '', additionalPrompts = '', }) => {
|
|
66
68
|
if (!openai) {
|
|
67
69
|
openai = new AzureOpenAI({
|
|
68
70
|
endpoint: process.env.AZURE_OPENAI_ENDPOINT ||
|
|
@@ -77,7 +79,7 @@ export const translate = async ({ source, sourceContent, target, targetContent =
|
|
|
77
79
|
messages: [
|
|
78
80
|
{
|
|
79
81
|
role: 'system',
|
|
80
|
-
content: await render(systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT, { sourceLang, targetLang, additionalPrompts }, { async: true }),
|
|
82
|
+
content: await render(systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT, { sourceLang, targetLang, userPrompt, additionalPrompts }, { async: true }),
|
|
81
83
|
},
|
|
82
84
|
{
|
|
83
85
|
role: 'user',
|
|
@@ -2,8 +2,9 @@ import { type RspressPlugin, type UserConfig } from '@rspress/core';
|
|
|
2
2
|
export type * from './walk.js';
|
|
3
3
|
export type * from './type.js';
|
|
4
4
|
export interface AutoSidebarPluginOptions {
|
|
5
|
-
|
|
5
|
+
ignore?: boolean;
|
|
6
|
+
export?: boolean;
|
|
6
7
|
collapsed?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const autoSidebar: (config: UserConfig, {
|
|
9
|
+
export declare const autoSidebar: (config: UserConfig, { ignore, export: export_ }: AutoSidebarPluginOptions) => Promise<UserConfig<import("@rspress/shared").DefaultThemeConfig>>;
|
|
9
10
|
export declare const autoSidebarPlugin: (options?: AutoSidebarPluginOptions) => RspressPlugin;
|
|
@@ -154,17 +154,26 @@ function processLocales(langs, versions, root, defaultLang, defaultVersion, exte
|
|
|
154
154
|
}));
|
|
155
155
|
}
|
|
156
156
|
const defaultExtensions = ['.mdx', '.md', '.tsx', '.jsx', '.ts', '.js'];
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
config.
|
|
160
|
-
|
|
157
|
+
const APIS_ROUTES = ['apis/**', '*/apis/**'];
|
|
158
|
+
export const autoSidebar = async (config, { ignore, export: export_ }) => {
|
|
159
|
+
const excludeRoutes = (ignore && config.internalRoutes) || [];
|
|
160
|
+
const route = (config.route ??= {});
|
|
161
|
+
if (export_ || excludeRoutes.length) {
|
|
162
|
+
if (export_) {
|
|
163
|
+
excludeRoutes.push(...APIS_ROUTES);
|
|
164
|
+
}
|
|
165
|
+
const exclude = (route.exclude ??= []);
|
|
166
|
+
exclude.push(...excludeRoutes);
|
|
167
|
+
}
|
|
168
|
+
config.themeConfig ??= {};
|
|
169
|
+
config.themeConfig.locales ??= config.locales || [];
|
|
161
170
|
const root = config.root;
|
|
162
171
|
const langs = config.themeConfig.locales.map((locale) => locale.lang);
|
|
163
172
|
const hasLocales = langs.length > 0;
|
|
164
173
|
const versions = config.multiVersion?.versions || [];
|
|
165
174
|
const defaultLang = config.lang || '';
|
|
166
175
|
const { default: defaultVersion = '' } = config.multiVersion || {};
|
|
167
|
-
const { extensions = defaultExtensions } =
|
|
176
|
+
const { extensions = defaultExtensions } = route;
|
|
168
177
|
const collapsed = config.sidebar?.collapsed;
|
|
169
178
|
if (hasLocales) {
|
|
170
179
|
const metaInfo = await processLocales(langs, versions, root, defaultLang, defaultVersion, extensions, excludeRoutes, collapsed);
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export const ACP_BASE = '/container_platform/';
|
|
2
|
-
export const FALSY_VALUES = new Set(['0', 'false', 'no', 'off', 'n', 'f']);
|
|
2
|
+
export const FALSY_VALUES = new Set(['', '0', 'false', 'no', 'off', 'n', 'f']);
|
|
3
|
+
export const JS_STR_FALSY_VALUES = new Set([
|
|
4
|
+
'',
|
|
5
|
+
'0',
|
|
6
|
+
'false',
|
|
7
|
+
'null',
|
|
8
|
+
'undefined',
|
|
9
|
+
]);
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"doom": "yarn swc-node src/cli/index.ts",
|
|
31
31
|
"export": "yarn doom export",
|
|
32
32
|
"fixture": "yarn dev fixture-docs",
|
|
33
|
+
"format": "prettier --write .",
|
|
33
34
|
"lint": "run-p 'lint:*'",
|
|
34
35
|
"lint:es": "eslint . --cache",
|
|
35
36
|
"lint:tsc": "tsc -b",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"translate": "yarn doom translate fixture-docs"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@inquirer/prompts": "^7.4.
|
|
44
|
+
"@inquirer/prompts": "^7.4.1",
|
|
44
45
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
45
46
|
"@playwright/browser-chromium": "^1.51.1",
|
|
46
47
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
@@ -70,32 +71,32 @@
|
|
|
70
71
|
"simple-git": "^3.27.0",
|
|
71
72
|
"swagger2openapi": "^7.0.8",
|
|
72
73
|
"tinyglobby": "^0.2.12",
|
|
73
|
-
"type-fest": "^4.39.
|
|
74
|
+
"type-fest": "^4.39.1",
|
|
74
75
|
"yaml": "^2.7.1",
|
|
75
76
|
"yoctocolors": "^2.1.1"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
|
-
"@eslint/js": "^9.
|
|
79
|
+
"@eslint/js": "^9.24.0",
|
|
79
80
|
"@swc-node/register": "^1.10.10",
|
|
80
|
-
"@swc/core": "1.11.
|
|
81
|
+
"@swc/core": "1.11.18",
|
|
81
82
|
"@types/cli-progress": "^3.11.6",
|
|
82
83
|
"@types/ejs": "^3.1.5",
|
|
83
|
-
"@types/node": "^18.19.
|
|
84
|
-
"@types/picomatch": "^
|
|
84
|
+
"@types/node": "^18.19.86",
|
|
85
|
+
"@types/picomatch": "^4.0.0",
|
|
85
86
|
"@types/react": "^18.3.20",
|
|
86
|
-
"@types/react-dom": "^18.3.
|
|
87
|
+
"@types/react-dom": "^18.3.6",
|
|
87
88
|
"@types/swagger2openapi": "^7.0.4",
|
|
88
89
|
"@unts/patch-package": "^8.1.1",
|
|
89
|
-
"eslint": "^9.
|
|
90
|
-
"eslint-import-resolver-typescript": "^4.3.
|
|
91
|
-
"eslint-plugin-import-x": "^4.10.
|
|
90
|
+
"eslint": "^9.24.0",
|
|
91
|
+
"eslint-import-resolver-typescript": "^4.3.2",
|
|
92
|
+
"eslint-plugin-import-x": "^4.10.2",
|
|
92
93
|
"lint-staged": "^15.5.0",
|
|
93
94
|
"npm-run-all2": "^7.0.2",
|
|
94
95
|
"prettier": "^3.5.3",
|
|
95
|
-
"prettier-plugin-pkg": "^0.
|
|
96
|
+
"prettier-plugin-pkg": "^0.19.0",
|
|
96
97
|
"simple-git-hooks": "^2.12.1",
|
|
97
|
-
"typescript": "^5.8.
|
|
98
|
-
"typescript-eslint": "^8.29.
|
|
98
|
+
"typescript": "^5.8.3",
|
|
99
|
+
"typescript-eslint": "^8.29.1",
|
|
99
100
|
"yarn-berry-deduplicate": "^6.1.1"
|
|
100
101
|
},
|
|
101
102
|
"publishConfig": {
|