@docusaurus/core 0.0.0-5833 → 0.0.0-5834
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/bin/docusaurus.mjs
CHANGED
|
@@ -85,6 +85,10 @@ cli
|
|
|
85
85
|
'-t, --typescript',
|
|
86
86
|
'copy TypeScript theme files when possible (default: false)',
|
|
87
87
|
)
|
|
88
|
+
.option(
|
|
89
|
+
'-j, --javascript',
|
|
90
|
+
'copy JavaScript theme files when possible (default: false)',
|
|
91
|
+
)
|
|
88
92
|
.option('--danger', 'enable swizzle for unsafe component of themes')
|
|
89
93
|
.option(
|
|
90
94
|
'--config <config>',
|
|
@@ -39,6 +39,7 @@ exports.actionStatusSuffix = actionStatusSuffix;
|
|
|
39
39
|
function normalizeOptions(options) {
|
|
40
40
|
return {
|
|
41
41
|
typescript: options.typescript ?? false,
|
|
42
|
+
javascript: options.javascript ?? false,
|
|
42
43
|
danger: options.danger ?? false,
|
|
43
44
|
list: options.list ?? false,
|
|
44
45
|
wrap: options.wrap ?? false,
|
|
@@ -10,6 +10,7 @@ exports.swizzle = void 0;
|
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
14
|
const themes_1 = require("./themes");
|
|
14
15
|
const components_1 = require("./components");
|
|
15
16
|
const tables_1 = require("./tables");
|
|
@@ -18,6 +19,24 @@ const actions_1 = require("./actions");
|
|
|
18
19
|
const config_1 = require("./config");
|
|
19
20
|
const prompts_1 = require("./prompts");
|
|
20
21
|
const context_1 = require("./context");
|
|
22
|
+
async function getLanguageForThemeName({ themeName, plugins, options, }) {
|
|
23
|
+
const plugin = (0, themes_1.getPluginByThemeName)(plugins, themeName);
|
|
24
|
+
const supportsTS = !!plugin.instance.getTypeScriptThemePath?.();
|
|
25
|
+
if (options.typescript) {
|
|
26
|
+
if (!supportsTS) {
|
|
27
|
+
throw new Error(logger_1.default.interpolate `Theme name=${plugin.instance.name} does not support the code=${'--typescript'} CLI option.`);
|
|
28
|
+
}
|
|
29
|
+
return 'typescript';
|
|
30
|
+
}
|
|
31
|
+
if (options.javascript) {
|
|
32
|
+
return 'javascript';
|
|
33
|
+
}
|
|
34
|
+
// It's only useful to prompt the user for themes that support both JS/TS
|
|
35
|
+
if (supportsTS) {
|
|
36
|
+
return (0, utils_1.askPreferredLanguage)({ exit: true });
|
|
37
|
+
}
|
|
38
|
+
return 'javascript';
|
|
39
|
+
}
|
|
21
40
|
async function listAllThemeComponents({ themeNames, plugins, typescript, }) {
|
|
22
41
|
const themeComponentsTables = (await Promise.all(themeNames.map(async (themeName) => {
|
|
23
42
|
const themePath = (0, themes_1.getThemePath)({ themeName, plugins, typescript });
|
|
@@ -61,14 +80,24 @@ If you want to swizzle it, use the code=${'--danger'} flag, or confirm that you
|
|
|
61
80
|
async function swizzle(themeNameParam = undefined, componentNameParam = undefined, siteDirParam = '.', optionsParam = {}) {
|
|
62
81
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
63
82
|
const options = (0, common_1.normalizeOptions)(optionsParam);
|
|
64
|
-
const { list, danger
|
|
83
|
+
const { list, danger } = options;
|
|
65
84
|
const { plugins } = await (0, context_1.initSwizzleContext)(siteDir, options);
|
|
66
85
|
const themeNames = (0, themes_1.getThemeNames)(plugins);
|
|
67
86
|
if (list && !themeNameParam) {
|
|
68
|
-
await listAllThemeComponents({
|
|
87
|
+
await listAllThemeComponents({
|
|
88
|
+
themeNames,
|
|
89
|
+
plugins,
|
|
90
|
+
typescript: options.typescript,
|
|
91
|
+
});
|
|
69
92
|
}
|
|
70
93
|
const themeName = await (0, themes_1.getThemeName)({ themeNameParam, themeNames, list });
|
|
71
|
-
const
|
|
94
|
+
const language = await getLanguageForThemeName({ themeName, plugins, options });
|
|
95
|
+
const typescript = language === 'typescript';
|
|
96
|
+
const themePath = (0, themes_1.getThemePath)({
|
|
97
|
+
themeName,
|
|
98
|
+
plugins,
|
|
99
|
+
typescript,
|
|
100
|
+
});
|
|
72
101
|
const swizzleConfig = (0, config_1.getThemeSwizzleConfig)(themeName, plugins);
|
|
73
102
|
const themeComponents = await (0, components_1.getThemeComponents)({
|
|
74
103
|
themeName,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5834",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.22.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
45
45
|
"@babel/traverse": "^7.22.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5834",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5834",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5834",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
52
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
50
|
+
"@docusaurus/utils": "0.0.0-5834",
|
|
51
|
+
"@docusaurus/utils-common": "0.0.0-5834",
|
|
52
|
+
"@docusaurus/utils-validation": "0.0.0-5834",
|
|
53
53
|
"@svgr/webpack": "^6.5.1",
|
|
54
54
|
"autoprefixer": "^10.4.14",
|
|
55
55
|
"babel-loader": "^9.1.3",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"webpackbar": "^5.0.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
109
|
-
"@docusaurus/types": "0.0.0-
|
|
108
|
+
"@docusaurus/module-type-aliases": "0.0.0-5834",
|
|
109
|
+
"@docusaurus/types": "0.0.0-5834",
|
|
110
110
|
"@types/detect-port": "^1.3.3",
|
|
111
111
|
"@types/react-dom": "^18.2.7",
|
|
112
112
|
"@types/react-router-config": "^5.0.7",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"engines": {
|
|
126
126
|
"node": ">=18.0"
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "61076da611615859ca4be6cb4be9c0275daf1554"
|
|
129
129
|
}
|