@alauda/doom 0.15.9 → 0.15.11
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseBoolean: (value: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const parseBoolean = (value) => !!value && !['0', 'false'].includes(value);
|
package/lib/cli/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { green } from 'yoctocolors';
|
|
|
12
12
|
import { setNodeEnv } from '../utils/index.js';
|
|
13
13
|
import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js';
|
|
14
14
|
import { exportCommand } from './export.js';
|
|
15
|
+
import { parseBoolean } from './helpers.js';
|
|
15
16
|
import { loadConfig } from './load-config.js';
|
|
16
17
|
import { newCommand } from './new.js';
|
|
17
18
|
import { translateCommand } from './translate.js';
|
|
@@ -32,16 +33,16 @@ program
|
|
|
32
33
|
.option('-p, --prefix <prefix>', 'Specify the prefix of the documentation base')
|
|
33
34
|
.option('-f, --force [boolean]', `Force to
|
|
34
35
|
1. fetch latest reference remotes or scaffolding templates, otherwise use local cache
|
|
35
|
-
2. translate ignore hash equality check and original text`,
|
|
36
|
-
.option('-i, --ignore [boolean]', 'Ignore internal routes',
|
|
37
|
-
.option('-d, --download [boolean]', 'Display download pdf link on nav bar',
|
|
36
|
+
2. translate ignore hash equality check and original text`, parseBoolean, false)
|
|
37
|
+
.option('-i, --ignore [boolean]', 'Ignore internal routes', parseBoolean, false)
|
|
38
|
+
.option('-d, --download [boolean]', 'Display download pdf link on nav bar', parseBoolean, false)
|
|
38
39
|
.option('--no-open [boolean]', 'Do not open the browser after starting the server')
|
|
39
40
|
.command('dev', { isDefault: true })
|
|
40
41
|
.description('Start the development server')
|
|
41
42
|
.argument('[root]', 'Root directory of the documentation')
|
|
42
43
|
.option('-H, --host [host]', 'Dev server host name')
|
|
43
44
|
.option('-P, --port [port]', 'Dev server port number')
|
|
44
|
-
.option('--
|
|
45
|
+
.option('-l, --lazy [boolean]', 'Whether to enable `lazyCompilation` which could improve the compilation performance', parseBoolean, false)
|
|
45
46
|
.action(async function (root) {
|
|
46
47
|
setNodeEnv('development');
|
|
47
48
|
let devServer;
|
package/lib/cli/new.js
CHANGED
|
@@ -104,7 +104,7 @@ export const newCommand = new Command('new')
|
|
|
104
104
|
const source = path.resolve(base, render(layout.source, { parameters }));
|
|
105
105
|
const target = path.resolve(render(layout.target, { parameters }));
|
|
106
106
|
const when = layout.when && render(layout.when, { parameters });
|
|
107
|
-
if (['', '
|
|
107
|
+
if (['', '0', 'false', 'null', 'undefined'].includes(when)) {
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
110
|
switch (layout.type) {
|
package/lib/cli/translate.js
CHANGED
|
@@ -13,6 +13,7 @@ import { cyan } from 'yoctocolors';
|
|
|
13
13
|
import { mdProcessor, mdxProcessor, normalizeImgSrc, } from '../plugins/index.js';
|
|
14
14
|
import { isDoc } from '../shared/index.js';
|
|
15
15
|
import { pathExists } from '../utils/index.js';
|
|
16
|
+
import { parseBoolean } from './helpers.js';
|
|
16
17
|
import { loadConfig } from './load-config.js';
|
|
17
18
|
const LANGUAGE_CODES = {
|
|
18
19
|
zh: '中文',
|
|
@@ -95,7 +96,7 @@ export const translateCommand = new Command('translate')
|
|
|
95
96
|
.option('-s, --source <language>', 'Document source language', 'zh')
|
|
96
97
|
.option('-t, --target <language>', 'Document target language', 'en')
|
|
97
98
|
.requiredOption('-g, --glob <path...>', 'Glob patterns for source dirs/files')
|
|
98
|
-
.option('-C, --copy [boolean]', 'Wether to copy relative assets to the target directory instead of following links',
|
|
99
|
+
.option('-C, --copy [boolean]', 'Wether to copy relative assets to the target directory instead of following links', parseBoolean, false)
|
|
99
100
|
.action(async function (root) {
|
|
100
101
|
const { source, target, glob: globs, copy, force, ...globalOptions } = this.optsWithGlobals();
|
|
101
102
|
if (!Object.hasOwn(LANGUAGE_CODES, source) ||
|
|
@@ -45,10 +45,10 @@ export const OpenAPIResponses = ({ responses, openapi, }) => {
|
|
|
45
45
|
if (type === 'object' &&
|
|
46
46
|
'properties' in schema &&
|
|
47
47
|
schema.properties) {
|
|
48
|
-
extraNode = (_jsxs("div", { className: "my-4", children: ["Properties:", _jsx(OpenAPIProperties, { properties: schema.properties, openapi: openapi })] }));
|
|
48
|
+
extraNode = (_jsxs("div", { className: "my-4", children: [_jsx("em", { children: "Properties:" }), _jsx(OpenAPIProperties, { properties: schema.properties, openapi: openapi })] }));
|
|
49
49
|
}
|
|
50
50
|
else if (type === 'array' && 'items' in schema && schema.items) {
|
|
51
|
-
extraNode = (_jsxs("div", { className: "my-4", children: ["Items:", _jsx(OpenAPIProperty, { property: schema.items, openapi: openapi })] }));
|
|
51
|
+
extraNode = (_jsxs("div", { className: "my-4", children: [_jsx("em", { children: "Items:" }), _jsx(OpenAPIProperty, { property: schema.items, openapi: openapi })] }));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
else if (type && '$ref' in type) {
|
|
@@ -11,6 +11,7 @@ export const OpenAPIProperty = ({ name, property, openapi, }) => {
|
|
|
11
11
|
const propObj = '$ref' in property ? resolveRef(openapi, property.$ref) : property;
|
|
12
12
|
const type = propObj.type;
|
|
13
13
|
let typeNode;
|
|
14
|
+
let extraNode;
|
|
14
15
|
if (type === 'array') {
|
|
15
16
|
const { items } = propObj;
|
|
16
17
|
const itemsObj = '$ref' in items ? resolveRef(openapi, items.$ref) : items;
|
|
@@ -18,6 +19,9 @@ export const OpenAPIProperty = ({ name, property, openapi, }) => {
|
|
|
18
19
|
typeNode = (_jsxs("code", { children: ["[]", '$ref' in items ? _jsx(RefLink, { "$ref": items.$ref }) : itemsType] }));
|
|
19
20
|
}
|
|
20
21
|
else if (type === 'object') {
|
|
22
|
+
if ('properties' in property && property.properties) {
|
|
23
|
+
extraNode = (_jsxs("div", { className: "my-4", children: [_jsx("em", { children: "Properties:" }), _jsx(OpenAPIProperties, { properties: property.properties, openapi: openapi })] }));
|
|
24
|
+
}
|
|
21
25
|
if (typeof propObj.additionalProperties === 'object') {
|
|
22
26
|
const props = propObj.additionalProperties;
|
|
23
27
|
const propsObj = '$ref' in props ? resolveRef(openapi, props.$ref) : props;
|
|
@@ -36,7 +40,7 @@ export const OpenAPIProperty = ({ name, property, openapi, }) => {
|
|
|
36
40
|
else if ('$ref' in property) {
|
|
37
41
|
typeNode = _jsx(RefLink, { "$ref": property.$ref });
|
|
38
42
|
}
|
|
39
|
-
return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx("code", { children: name }), ":", ' '] })), typeNode, _jsx(Markdown, { children: propObj.description })] }));
|
|
43
|
+
return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx("code", { children: name }), ":", ' '] })), typeNode, _jsx(Markdown, { children: propObj.description }), extraNode] }));
|
|
40
44
|
};
|
|
41
45
|
export const OpenAPIProperties = ({ properties, openapi, }) => {
|
|
42
46
|
const [X] = useState(getCustomMDXComponent);
|