@alauda/doom 1.0.0-next.4 → 1.0.0-next.6
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/helpers.d.ts +1 -0
- package/lib/cli/helpers.js +3 -1
- package/lib/cli/index.js +3 -5
- package/lib/cli/load-config.js +9 -5
- package/lib/cli/translate.js +1 -1
- package/lib/plugins/replace/resolve-release.js +1 -1
- package/lib/plugins/shiki/index.d.ts +0 -1
- package/lib/plugins/shiki/index.js +0 -1
- package/lib/types.d.ts +1 -1
- package/package.json +8 -9
- package/lib/plugins/shiki/rehype-fix.d.ts +0 -9
- package/lib/plugins/shiki/rehype-fix.js +0 -25
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const parseBoolean: (value?: string) => boolean;
|
|
2
|
+
export declare const parseBooleanOrString: (value?: string) => string | boolean;
|
|
2
3
|
export declare const getMatchedDocFilePaths: (matched: string[]) => Promise<(string | string[])[]>;
|
|
3
4
|
/**
|
|
4
5
|
* Support custom id like `#hello world {#custom-id}`
|
package/lib/cli/helpers.js
CHANGED
|
@@ -2,8 +2,10 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import { glob } from 'tinyglobby';
|
|
3
3
|
import { xfetch } from 'x-fetch';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
|
-
import { FALSY_VALUES } from '../shared/index.js';
|
|
5
|
+
import { FALSY_VALUES, TRUTHY_VALUES } from '../shared/index.js';
|
|
6
6
|
export const parseBoolean = (value) => value === undefined || !FALSY_VALUES.has(value);
|
|
7
|
+
export const parseBooleanOrString = (value) => value === undefined ||
|
|
8
|
+
(FALSY_VALUES.has(value) ? false : TRUTHY_VALUES.has(value) || value);
|
|
7
9
|
const DOC_PATTERN = /\.mdx?$/;
|
|
8
10
|
const isDoc = (filename) => DOC_PATTERN.test(filename);
|
|
9
11
|
export const getMatchedDocFilePaths = (matched) => Promise.all(matched.map(async (it) => {
|
package/lib/cli/index.js
CHANGED
|
@@ -9,11 +9,10 @@ import { build, dev, serve } from '@rspress/core';
|
|
|
9
9
|
import { watch } from 'chokidar';
|
|
10
10
|
import { program } from 'commander';
|
|
11
11
|
import { green } from 'yoctocolors';
|
|
12
|
-
import { FALSY_VALUES, TRUTHY_VALUES } from '../shared/index.js';
|
|
13
12
|
import { setNodeEnv } from '../utils/index.js';
|
|
14
13
|
import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js';
|
|
15
14
|
import { exportCommand } from './export.js';
|
|
16
|
-
import { parseBoolean } from './helpers.js';
|
|
15
|
+
import { parseBoolean, parseBooleanOrString } from './helpers.js';
|
|
17
16
|
import { lintCommand } from './lint.js';
|
|
18
17
|
import { loadConfig } from './load-config.js';
|
|
19
18
|
import { newCommand } from './new.js';
|
|
@@ -43,9 +42,8 @@ program
|
|
|
43
42
|
.option('-E, --exclude <language...>', 'Include all languages except the specific language(s), `ru` for example')
|
|
44
43
|
.option('-o, --out-dir <path>', 'Override the `outDir` defined in the config file or the default `dist/{base}/{version}`, the resulting path will be `dist/{outDir}/{version}`')
|
|
45
44
|
.option('-r, --redirect <enum>', 'Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang`', 'only-default-lang')
|
|
46
|
-
.option('-R, --edit-repo [boolean|url]', 'Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted',
|
|
47
|
-
|
|
48
|
-
.option('-a, --algolia', 'Whether to enable Algolia search', parseBoolean, false)
|
|
45
|
+
.option('-R, --edit-repo [boolean|url]', 'Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted', parseBooleanOrString, false)
|
|
46
|
+
.option('-a, --algolia [boolean|alauda]', 'Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search', parseBooleanOrString, false)
|
|
49
47
|
.option('-S, --site-url', 'Whether to enable the siteUrl for sitemap generation', parseBoolean, false)
|
|
50
48
|
.option('-n, --no-open [boolean]', 'Do not open the browser after starting the server')
|
|
51
49
|
.command('dev', { isDefault: true })
|
package/lib/cli/load-config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { nodeTypes } from '@mdx-js/mdx';
|
|
4
3
|
import { pluginSass } from '@rsbuild/plugin-sass';
|
|
5
4
|
import { pluginYaml } from '@rsbuild/plugin-yaml';
|
|
6
5
|
import { addLeadingSlash, addTrailingSlash, normalizeSlash, removeLeadingSlash, } from '@rspress/core';
|
|
@@ -9,9 +8,8 @@ import { pluginLlms } from '@rspress/plugin-llms';
|
|
|
9
8
|
import { logger } from '@rspress/shared/logger';
|
|
10
9
|
import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
|
|
11
10
|
import { difference } from 'es-toolkit';
|
|
12
|
-
import rehypeRaw from 'rehype-raw';
|
|
13
11
|
import { cyan } from 'yoctocolors';
|
|
14
|
-
import { apiPlugin, autoSidebarPlugin, autoTocPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin,
|
|
12
|
+
import { apiPlugin, autoSidebarPlugin, autoTocPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, sitemapPlugin, } from '../plugins/index.js';
|
|
15
13
|
import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
|
|
16
14
|
import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
|
|
17
15
|
import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
@@ -49,6 +47,11 @@ const KNOWN_LOCALE_CONFIGS = {
|
|
|
49
47
|
},
|
|
50
48
|
},
|
|
51
49
|
};
|
|
50
|
+
const ALAUDA_ALGOLIA_OPTIONS = {
|
|
51
|
+
appId: 'XN35Q5JLSV',
|
|
52
|
+
apiKey: '487fb969bdcda09dd4950468d7d8b61e',
|
|
53
|
+
indexName: 'docs_alauda_io_xn35q5jlsv_pages',
|
|
54
|
+
};
|
|
52
55
|
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, include, exclude, redirect, editRepo, algolia, siteUrl, }) => {
|
|
53
56
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
54
57
|
root = resolveDocRoot(CWD, root, config.root);
|
|
@@ -106,7 +109,9 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
106
109
|
}
|
|
107
110
|
const unusedLanguages = difference(allLanguages, locales.map(({ lang }) => lang));
|
|
108
111
|
const { editLink, ...zhLocale } = KNOWN_LOCALE_CONFIGS.zh;
|
|
109
|
-
const algoliaOptions = algolia
|
|
112
|
+
const algoliaOptions = ((algolia && config.algolia) ??
|
|
113
|
+
(algolia === 'alauda' && ALAUDA_ALGOLIA_OPTIONS)) ||
|
|
114
|
+
null;
|
|
110
115
|
return {
|
|
111
116
|
userBase,
|
|
112
117
|
root,
|
|
@@ -128,7 +133,6 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
128
133
|
},
|
|
129
134
|
markdown: {
|
|
130
135
|
checkDeadLinks: true,
|
|
131
|
-
rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }], rehypeFix],
|
|
132
136
|
shiki: {
|
|
133
137
|
transformers: [
|
|
134
138
|
// builtin transformers
|
package/lib/cli/translate.js
CHANGED
|
@@ -90,7 +90,7 @@ export const translate = async ({ source, sourceContent, target, targetContent =
|
|
|
90
90
|
terms = await resolveTerms();
|
|
91
91
|
}
|
|
92
92
|
const finalSystemPrompt = await render(systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT, { sourceLang, targetLang, userPrompt, additionalPrompts, terms }, { async: true });
|
|
93
|
-
const { choices } = await openai.
|
|
93
|
+
const { choices } = await openai.chat.completions.parse({
|
|
94
94
|
messages: [
|
|
95
95
|
{
|
|
96
96
|
role: 'system',
|
|
@@ -85,7 +85,7 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
85
85
|
catch (err) {
|
|
86
86
|
if (err instanceof ResponseError) {
|
|
87
87
|
const error = err;
|
|
88
|
-
logger.error(`Failed to fetch release notes for query \`${red(releaseQuery)}\` with status \`${error.response.status}\` and ${error.data ? `data ${JSON.stringify(data, null, 2)}` : `message \`${error.message}\``}`);
|
|
88
|
+
logger.error(`Failed to fetch release notes for query \`${red(releaseQuery)}\` with status \`${error.response.status}\` and ${error.data ? `data ${JSON.stringify(error.data, null, 2)}` : `message \`${error.message}\``}`);
|
|
89
89
|
}
|
|
90
90
|
return;
|
|
91
91
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface GlobalCliOptions {
|
|
|
20
20
|
outDir?: string;
|
|
21
21
|
redirect?: 'auto' | 'never' | 'only-default-lang';
|
|
22
22
|
editRepo?: boolean | string;
|
|
23
|
-
algolia?: boolean;
|
|
23
|
+
algolia?: boolean | 'alauda';
|
|
24
24
|
siteUrl?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export interface TranslateOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "git+https://github.com/alauda/doom.git",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cspell/eslint-plugin": "^9.0.2",
|
|
38
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
38
|
+
"@eslint-react/eslint-plugin": "^1.51.0",
|
|
39
39
|
"@inquirer/prompts": "^7.5.3",
|
|
40
40
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
41
41
|
"@playwright/browser-chromium": "^1.52.0",
|
|
42
42
|
"@rsbuild/plugin-sass": "^1.3.1",
|
|
43
43
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
44
|
-
"@rspress/core": "2.0.0-beta.
|
|
45
|
-
"@rspress/plugin-algolia": "2.0.0-beta.
|
|
46
|
-
"@rspress/plugin-llms": "^2.0.0-beta.
|
|
44
|
+
"@rspress/core": "2.0.0-beta.10",
|
|
45
|
+
"@rspress/plugin-algolia": "2.0.0-beta.10",
|
|
46
|
+
"@rspress/plugin-llms": "^2.0.0-beta.10",
|
|
47
47
|
"@shikijs/transformers": "^3.4.2",
|
|
48
48
|
"chokidar": "^4.0.3",
|
|
49
49
|
"cli-progress": "^3.12.0",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"commander": "^13.1.0",
|
|
52
52
|
"ejs": "^3.1.10",
|
|
53
53
|
"es-toolkit": "^1.38.0",
|
|
54
|
-
"eslint": "^9.
|
|
54
|
+
"eslint": "^9.28.0",
|
|
55
55
|
"eslint-plugin-mdx": "^3.4.2",
|
|
56
56
|
"html-tag-names": "^2.1.0",
|
|
57
57
|
"mdast-util-mdx": "^3.0.0",
|
|
58
58
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
59
59
|
"mermaid": "^11.6.0",
|
|
60
|
-
"openai": "^5.
|
|
60
|
+
"openai": "^5.1.0",
|
|
61
61
|
"openapi-types": "^12.1.3",
|
|
62
62
|
"p-ratelimit": "^1.0.1",
|
|
63
63
|
"pdf-lib": "^1.17.1",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"picomatch": "^4.0.2",
|
|
66
66
|
"playwright": "^1.52.0",
|
|
67
67
|
"react-markdown": "^10.1.0",
|
|
68
|
-
"rehype-raw": "^7.0.0",
|
|
69
68
|
"remark-directive": "^4.0.0",
|
|
70
69
|
"remark-frontmatter": "^5.0.0",
|
|
71
70
|
"remark-gfm": "^4.0.1",
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
"swagger2openapi": "^7.0.8",
|
|
77
76
|
"tinyglobby": "^0.2.14",
|
|
78
77
|
"type-fest": "^4.41.0",
|
|
79
|
-
"typescript-eslint": "^8.33.
|
|
78
|
+
"typescript-eslint": "^8.33.1",
|
|
80
79
|
"x-fetch": "^0.2.6",
|
|
81
80
|
"yaml": "^2.8.0",
|
|
82
81
|
"yoctocolors": "^2.1.1"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'hast';
|
|
2
|
-
import type { Plugin } from 'unified';
|
|
3
|
-
/**
|
|
4
|
-
* Restores metadata (e.g., titles) for code blocks that `rehype-raw` removes unexpectedly.
|
|
5
|
-
* This function addresses a compatibility issue where `rehype-raw` strips metadata from code blocks.
|
|
6
|
-
* @see https://github.com/syntax-tree/hast-util-raw/issues/29
|
|
7
|
-
* @see https://github.com/web-infra-dev/rspress/blob/ab7567460e63712300b64d7ab46065a2f1c1e069/packages/core/src/node/mdx/rehypePlugins/codeMeta.ts#L5-L22
|
|
8
|
-
*/
|
|
9
|
-
export declare const rehypeFix: Plugin<[], Root>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { visit } from 'unist-util-visit';
|
|
2
|
-
/**
|
|
3
|
-
* Restores metadata (e.g., titles) for code blocks that `rehype-raw` removes unexpectedly.
|
|
4
|
-
* This function addresses a compatibility issue where `rehype-raw` strips metadata from code blocks.
|
|
5
|
-
* @see https://github.com/syntax-tree/hast-util-raw/issues/29
|
|
6
|
-
* @see https://github.com/web-infra-dev/rspress/blob/ab7567460e63712300b64d7ab46065a2f1c1e069/packages/core/src/node/mdx/rehypePlugins/codeMeta.ts#L5-L22
|
|
7
|
-
*/
|
|
8
|
-
export const rehypeFix = function () {
|
|
9
|
-
return (ast) => {
|
|
10
|
-
visit(ast, 'element', (node) => {
|
|
11
|
-
// <pre><code>...</code></pre>
|
|
12
|
-
// 1. Find pre element
|
|
13
|
-
const childNode = node.children.at(0);
|
|
14
|
-
if (node.tagName === 'pre' &&
|
|
15
|
-
childNode?.type === 'element' &&
|
|
16
|
-
childNode.tagName === 'code') {
|
|
17
|
-
if (!childNode.data?.meta &&
|
|
18
|
-
typeof childNode.properties.meta === 'string') {
|
|
19
|
-
;
|
|
20
|
-
(childNode.data ??= {}).meta ??= childNode.properties.meta;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
};
|