@docusaurus/core 0.0.0-4258 → 0.0.0-4263
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/.tsbuildinfo +1 -1
- package/lib/babel/preset.d.ts +6 -0
- package/lib/babel/preset.js +2 -2
- package/lib/client/.eslintrc.js +0 -1
- package/lib/commands/clear.d.ts +6 -0
- package/lib/commands/clear.js +7 -7
- package/lib/commands/commandUtils.d.ts +6 -0
- package/lib/commands/commandUtils.js +5 -5
- package/lib/commands/swizzle.js +18 -18
- package/lib/commands/writeTranslations.js +6 -0
- package/lib/server/configValidation.js +3 -3
- package/lib/server/duplicateRoutes.js +6 -0
- package/lib/server/i18n.js +8 -3
- package/lib/server/index.js +6 -7
- package/lib/server/plugins/index.js +2 -3
- package/lib/server/plugins/init.js +2 -2
- package/lib/server/plugins/pluginIds.js +4 -4
- package/lib/server/themes/index.js +2 -2
- package/lib/server/translations/translations.d.ts +6 -0
- package/lib/server/translations/translations.js +3 -3
- package/lib/server/translations/translationsExtractor.d.ts +6 -0
- package/lib/server/translations/translationsExtractor.js +7 -7
- package/lib/webpack/base.js +1 -1
- package/lib/webpack/plugins/LogPlugin.js +2 -2
- package/lib/webpack/server.js +2 -2
- package/lib/webpack/utils.d.ts +0 -22
- package/lib/webpack/utils.js +3 -99
- package/package.json +9 -8
- package/lib/constants.d.ts +0 -19
- package/lib/constants.js +0 -26
package/lib/commands/clear.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
2
|
/**
|
|
5
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
*
|
|
7
5
|
* This source code is licensed under the MIT license found in the
|
|
8
6
|
* LICENSE file in the root directory of this source tree.
|
|
9
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
10
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
11
11
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
13
|
+
const utils_1 = require("@docusaurus/utils");
|
|
14
14
|
function removePath(fsPath) {
|
|
15
15
|
return fs_extra_1.default
|
|
16
16
|
.remove(path_1.default.join(fsPath))
|
|
17
17
|
.then(() => {
|
|
18
|
-
console.log(
|
|
18
|
+
console.log(chalk_1.default.green(`Successfully removed "${fsPath}" directory.`));
|
|
19
19
|
})
|
|
20
20
|
.catch((err) => {
|
|
21
21
|
console.error(`Could not remove ${fsPath} directory.`);
|
|
@@ -24,8 +24,8 @@ function removePath(fsPath) {
|
|
|
24
24
|
}
|
|
25
25
|
async function clear(siteDir) {
|
|
26
26
|
return Promise.all([
|
|
27
|
-
removePath(path_1.default.join(siteDir,
|
|
28
|
-
removePath(path_1.default.join(siteDir,
|
|
27
|
+
removePath(path_1.default.join(siteDir, utils_1.GENERATED_FILES_DIR_NAME)),
|
|
28
|
+
removePath(path_1.default.join(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME)),
|
|
29
29
|
removePath(path_1.default.join(siteDir, 'node_modules', '.cache')),
|
|
30
30
|
]);
|
|
31
31
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
1
7
|
import { HostPortCLIOptions } from '@docusaurus/types';
|
|
2
8
|
export declare function getCLIOptionHost(hostOption: HostPortCLIOptions['host']): string;
|
|
3
9
|
export declare function getCLIOptionPort(portOption: HostPortCLIOptions['port'], host: string): Promise<number | null>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCLIOptionPort = exports.getCLIOptionHost = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
2
|
/**
|
|
6
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
4
|
*
|
|
8
5
|
* This source code is licensed under the MIT license found in the
|
|
9
6
|
* LICENSE file in the root directory of this source tree.
|
|
10
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getCLIOptionPort = exports.getCLIOptionHost = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
11
|
const choosePort_1 = (0, tslib_1.__importDefault)(require("../choosePort"));
|
|
12
|
-
const
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
function getCLIOptionHost(hostOption) {
|
|
14
14
|
return hostOption || 'localhost';
|
|
15
15
|
}
|
|
16
16
|
exports.getCLIOptionHost = getCLIOptionHost;
|
|
17
17
|
async function getCLIOptionPort(portOption, host) {
|
|
18
|
-
const basePort = portOption ? parseInt(portOption, 10) :
|
|
18
|
+
const basePort = portOption ? parseInt(portOption, 10) : utils_1.DEFAULT_PORT;
|
|
19
19
|
return (0, choosePort_1.default)(host, basePort);
|
|
20
20
|
}
|
|
21
21
|
exports.getCLIOptionPort = getCLIOptionPort;
|
package/lib/commands/swizzle.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getPluginNames = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
12
12
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
13
13
|
const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
|
|
14
14
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
15
15
|
const leven_1 = (0, tslib_1.__importDefault)(require("leven"));
|
|
16
16
|
const lodash_1 = require("lodash");
|
|
17
|
-
const
|
|
17
|
+
const utils_1 = require("@docusaurus/utils");
|
|
18
18
|
const server_1 = require("../server");
|
|
19
19
|
const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
|
|
20
20
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
@@ -82,13 +82,13 @@ function getComponentName(themePath, plugin, danger) {
|
|
|
82
82
|
function themeComponents(themePath, plugin) {
|
|
83
83
|
const components = colorCode(themePath, plugin);
|
|
84
84
|
if (components.length === 0) {
|
|
85
|
-
return `${
|
|
85
|
+
return `${chalk_1.default.red('No component to swizzle.')}`;
|
|
86
86
|
}
|
|
87
87
|
return `
|
|
88
|
-
${
|
|
88
|
+
${chalk_1.default.cyan('Theme components available for swizzle.')}
|
|
89
89
|
|
|
90
|
-
${
|
|
91
|
-
${
|
|
90
|
+
${chalk_1.default.green('green =>')} safe: lower breaking change risk
|
|
91
|
+
${chalk_1.default.red('red =>')} unsafe: higher breaking change risk
|
|
92
92
|
|
|
93
93
|
${components.join('\n')}
|
|
94
94
|
`;
|
|
@@ -106,8 +106,8 @@ function colorCode(themePath, plugin) {
|
|
|
106
106
|
: [];
|
|
107
107
|
const [greenComponents, redComponents] = (0, lodash_1.partition)(components, (comp) => allowedComponent.includes(comp));
|
|
108
108
|
return [
|
|
109
|
-
...greenComponents.map((component) =>
|
|
110
|
-
...redComponents.map((component) =>
|
|
109
|
+
...greenComponents.map((component) => chalk_1.default.green(`safe: ${component}`)),
|
|
110
|
+
...redComponents.map((component) => chalk_1.default.red(`unsafe: ${component}`)),
|
|
111
111
|
];
|
|
112
112
|
}
|
|
113
113
|
async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
@@ -137,7 +137,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
137
137
|
suggestion = name;
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
|
-
|
|
140
|
+
chalk_1.default.red(`Theme ${themeName} not found. ${suggestion
|
|
141
141
|
? `Did you mean "${suggestion}" ?`
|
|
142
142
|
: formattedThemeNames(themeNames)}`);
|
|
143
143
|
process.exit(1);
|
|
@@ -171,7 +171,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
171
171
|
? (_d = pluginInstance.getTypeScriptThemePath) === null || _d === void 0 ? void 0 : _d.call(pluginInstance)
|
|
172
172
|
: (_e = pluginInstance.getThemePath) === null || _e === void 0 ? void 0 : _e.call(pluginInstance);
|
|
173
173
|
if (!themePath) {
|
|
174
|
-
console.warn(
|
|
174
|
+
console.warn(chalk_1.default.yellow(typescript
|
|
175
175
|
? `${themeName} does not provide TypeScript theme code via "getTypeScriptThemePath()".`
|
|
176
176
|
: `${themeName} does not provide any theme code.`));
|
|
177
177
|
process.exit(1);
|
|
@@ -199,11 +199,11 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
199
199
|
});
|
|
200
200
|
if (mostSuitableMatch !== componentName) {
|
|
201
201
|
mostSuitableComponent = mostSuitableMatch;
|
|
202
|
-
console.log(
|
|
202
|
+
console.log(chalk_1.default.red(`Component "${componentName}" doesn't exist.`), chalk_1.default.yellow(`"${mostSuitableComponent}" is swizzled instead of "${componentName}".`));
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
let fromPath = path_1.default.join(themePath, mostSuitableComponent);
|
|
206
|
-
let toPath = path_1.default.resolve(siteDir,
|
|
206
|
+
let toPath = path_1.default.resolve(siteDir, utils_1.THEME_PATH, mostSuitableComponent);
|
|
207
207
|
// Handle single TypeScript/JavaScript file only.
|
|
208
208
|
// E.g: if <fromPath> does not exist, we try to swizzle <fromPath>.(ts|tsx|js) instead
|
|
209
209
|
if (!fs_extra_1.default.existsSync(fromPath)) {
|
|
@@ -223,7 +223,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
223
223
|
suggestion = name;
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
|
-
console.warn(
|
|
226
|
+
console.warn(chalk_1.default.red(`Component ${mostSuitableComponent} not found.`));
|
|
227
227
|
console.warn(suggestion
|
|
228
228
|
? `Did you mean "${suggestion}"?`
|
|
229
229
|
: `${themeComponents(themePath, pluginModule)}`);
|
|
@@ -231,15 +231,15 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
if (!components.includes(mostSuitableComponent) && !danger) {
|
|
234
|
-
console.warn(
|
|
234
|
+
console.warn(chalk_1.default.red(`${mostSuitableComponent} is an internal component and has a higher breaking change probability. If you want to swizzle it, use the "--danger" flag.`));
|
|
235
235
|
process.exit(1);
|
|
236
236
|
}
|
|
237
237
|
await fs_extra_1.default.copy(fromPath, toPath);
|
|
238
238
|
const relativeDir = path_1.default.relative(process.cwd(), toPath);
|
|
239
|
-
const fromMsg =
|
|
240
|
-
? `${themeName} ${
|
|
239
|
+
const fromMsg = chalk_1.default.blue(mostSuitableComponent
|
|
240
|
+
? `${themeName} ${chalk_1.default.yellow(mostSuitableComponent)}`
|
|
241
241
|
: themeName);
|
|
242
|
-
const toMsg =
|
|
243
|
-
console.log(`\n${
|
|
242
|
+
const toMsg = chalk_1.default.cyan(relativeDir);
|
|
243
|
+
console.log(`\n${chalk_1.default.green('Success!')} Copied ${fromMsg} to ${toMsg}.\n`);
|
|
244
244
|
}
|
|
245
245
|
exports.default = swizzle;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
const tslib_1 = require("tslib");
|
|
4
10
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateConfig = exports.ConfigSchema = exports.DEFAULT_CONFIG = exports.DEFAULT_I18N_CONFIG = void 0;
|
|
10
|
-
const
|
|
10
|
+
const utils_1 = require("@docusaurus/utils");
|
|
11
11
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
12
12
|
const DEFAULT_I18N_LOCALE = 'en';
|
|
13
13
|
exports.DEFAULT_I18N_CONFIG = {
|
|
@@ -28,7 +28,7 @@ exports.DEFAULT_CONFIG = {
|
|
|
28
28
|
titleDelimiter: '|',
|
|
29
29
|
noIndex: false,
|
|
30
30
|
baseUrlIssueBanner: true,
|
|
31
|
-
staticDirectories: [
|
|
31
|
+
staticDirectories: [utils_1.STATIC_DIR_NAME],
|
|
32
32
|
};
|
|
33
33
|
const PluginSchema = utils_validation_1.Joi.alternatives()
|
|
34
34
|
.try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array().ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required()), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
|
|
@@ -160,7 +160,7 @@ function validateConfig(config) {
|
|
|
160
160
|
? `${accumulatedErr}${err.message}\n`
|
|
161
161
|
: accumulatedErr, '');
|
|
162
162
|
formattedError = unknownFields
|
|
163
|
-
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${
|
|
163
|
+
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${utils_1.DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/docusaurus.config.js/#customfields`
|
|
164
164
|
: formattedError;
|
|
165
165
|
throw new Error(formattedError);
|
|
166
166
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.handleDuplicateRoutes = exports.getDuplicateRoutesMessage = exports.getAllDuplicateRoutes = void 0;
|
|
4
10
|
const utils_1 = require("@docusaurus/utils");
|
package/lib/server/i18n.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.localizePath = exports.loadI18n = exports.shouldWarnAboutNodeVersion = exports.getDefaultLocaleConfig = void 0;
|
|
4
10
|
const tslib_1 = require("tslib");
|
|
5
11
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
12
|
const utils_1 = require("@docusaurus/utils");
|
|
7
13
|
const rtl_detect_1 = require("rtl-detect");
|
|
8
|
-
const constants_1 = require("../constants");
|
|
9
14
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
10
15
|
function getDefaultLocaleLabel(locale) {
|
|
11
16
|
// Intl.DisplayNames is ES2021 - Node14+
|
|
@@ -41,8 +46,8 @@ Note: Docusaurus only support running one locale at a time.`));
|
|
|
41
46
|
const locales = i18nConfig.locales.includes(currentLocale)
|
|
42
47
|
? i18nConfig.locales
|
|
43
48
|
: i18nConfig.locales.concat(currentLocale);
|
|
44
|
-
if (shouldWarnAboutNodeVersion(
|
|
45
|
-
console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use Node.js 14 or later (instead of ${
|
|
49
|
+
if (shouldWarnAboutNodeVersion(utils_1.NODE_MAJOR_VERSION, locales)) {
|
|
50
|
+
console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use Node.js 14 or later (instead of ${utils_1.NODE_MAJOR_VERSION}).`));
|
|
46
51
|
}
|
|
47
52
|
function getLocaleConfig(locale) {
|
|
48
53
|
return {
|
package/lib/server/index.js
CHANGED
|
@@ -12,7 +12,6 @@ const utils_1 = require("@docusaurus/utils");
|
|
|
12
12
|
const path_1 = (0, tslib_1.__importStar)(require("path"));
|
|
13
13
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
14
14
|
const ssr_html_template_1 = (0, tslib_1.__importDefault)(require("../client/templates/ssr.html.template"));
|
|
15
|
-
const constants_1 = require("../constants");
|
|
16
15
|
const client_modules_1 = (0, tslib_1.__importDefault)(require("./client-modules"));
|
|
17
16
|
const config_1 = (0, tslib_1.__importDefault)(require("./config"));
|
|
18
17
|
const plugins_1 = require("./plugins");
|
|
@@ -28,7 +27,7 @@ const remark_admonitions_1 = (0, tslib_1.__importDefault)(require("remark-admoni
|
|
|
28
27
|
const module_1 = require("module");
|
|
29
28
|
const moduleShorthand_1 = require("./moduleShorthand");
|
|
30
29
|
async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
31
|
-
const siteConfigPathUnresolved = customConfigFilePath !== null && customConfigFilePath !== void 0 ? customConfigFilePath :
|
|
30
|
+
const siteConfigPathUnresolved = customConfigFilePath !== null && customConfigFilePath !== void 0 ? customConfigFilePath : utils_1.DEFAULT_CONFIG_FILE_NAME;
|
|
32
31
|
const siteConfigPath = path_1.default.isAbsolute(siteConfigPathUnresolved)
|
|
33
32
|
? siteConfigPathUnresolved
|
|
34
33
|
: path_1.default.resolve(siteDir, siteConfigPathUnresolved);
|
|
@@ -39,9 +38,9 @@ exports.loadSiteConfig = loadSiteConfig;
|
|
|
39
38
|
async function loadContext(siteDir, options = {}) {
|
|
40
39
|
var _a;
|
|
41
40
|
const { customOutDir, locale, customConfigFilePath } = options;
|
|
42
|
-
const generatedFilesDir = path_1.default.isAbsolute(
|
|
43
|
-
?
|
|
44
|
-
: path_1.default.resolve(siteDir,
|
|
41
|
+
const generatedFilesDir = path_1.default.isAbsolute(utils_1.GENERATED_FILES_DIR_NAME)
|
|
42
|
+
? utils_1.GENERATED_FILES_DIR_NAME
|
|
43
|
+
: path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
|
|
45
44
|
const { siteConfig: initialSiteConfig, siteConfigPath } = await loadSiteConfig({
|
|
46
45
|
siteDir,
|
|
47
46
|
customConfigFilePath,
|
|
@@ -49,7 +48,7 @@ async function loadContext(siteDir, options = {}) {
|
|
|
49
48
|
const { ssrTemplate } = initialSiteConfig;
|
|
50
49
|
const baseOutDir = customOutDir
|
|
51
50
|
? path_1.default.resolve(customOutDir)
|
|
52
|
-
: path_1.default.resolve(siteDir,
|
|
51
|
+
: path_1.default.resolve(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME);
|
|
53
52
|
const i18n = await (0, i18n_1.loadI18n)(initialSiteConfig, { locale });
|
|
54
53
|
const baseUrl = (0, i18n_1.localizePath)({
|
|
55
54
|
path: initialSiteConfig.baseUrl,
|
|
@@ -211,7 +210,7 @@ async function load(siteDir, options = {}) {
|
|
|
211
210
|
(0, duplicateRoutes_1.handleDuplicateRoutes)(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
|
|
212
211
|
// Site config must be generated after plugins
|
|
213
212
|
// We want the generated config to have been normalized by the plugins!
|
|
214
|
-
const genSiteConfig = (0, utils_1.generate)(generatedFilesDir,
|
|
213
|
+
const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, utils_1.DEFAULT_CONFIG_FILE_NAME, `export default ${JSON.stringify(siteConfig, null, 2)};`);
|
|
215
214
|
plugins.push(createBootstrapPlugin({ siteConfig }));
|
|
216
215
|
plugins.push(createMDXFallbackPlugin({ siteDir, siteConfig }));
|
|
217
216
|
// Load client modules.
|
|
@@ -13,7 +13,6 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
|
13
13
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
14
14
|
const init_1 = (0, tslib_1.__importDefault)(require("./init"));
|
|
15
15
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
16
|
-
const constants_1 = require("../../constants");
|
|
17
16
|
const lodash_1 = require("lodash");
|
|
18
17
|
const translations_1 = require("../translations/translations");
|
|
19
18
|
const applyRouteTrailingSlash_1 = (0, tslib_1.__importDefault)(require("./applyRouteTrailingSlash"));
|
|
@@ -84,7 +83,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
84
83
|
const allContent = (0, lodash_1.chain)(loadedPlugins)
|
|
85
84
|
.groupBy((item) => item.name)
|
|
86
85
|
.mapValues((nameItems) => (0, lodash_1.chain)(nameItems)
|
|
87
|
-
.groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a :
|
|
86
|
+
.groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; })
|
|
88
87
|
.mapValues((idItems) => idItems[0].content)
|
|
89
88
|
.value())
|
|
90
89
|
.value();
|
|
@@ -96,7 +95,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
96
95
|
if (!plugin.contentLoaded) {
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
99
|
-
const pluginId = (_a = plugin.options.id) !== null && _a !== void 0 ? _a :
|
|
98
|
+
const pluginId = (_a = plugin.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID;
|
|
100
99
|
// plugins data files are namespaced by pluginName/pluginId
|
|
101
100
|
const dataDirRoot = path_1.default.join(context.generatedFilesDir, plugin.name);
|
|
102
101
|
const dataDir = path_1.default.join(dataDirRoot, pluginId);
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const module_1 = require("module");
|
|
11
11
|
const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
|
|
12
|
-
const
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
const versions_1 = require("../versions");
|
|
14
14
|
const pluginIds_1 = require("./pluginIds");
|
|
15
15
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
@@ -126,7 +126,7 @@ function initPlugins({ pluginConfigs, context, }) {
|
|
|
126
126
|
// as we don't go through the Joi schema that adds it
|
|
127
127
|
return {
|
|
128
128
|
...normalizedPluginConfig.options,
|
|
129
|
-
id: (_a = normalizedPluginConfig.options.id) !== null && _a !== void 0 ? _a :
|
|
129
|
+
id: (_a = normalizedPluginConfig.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID,
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ensureUniquePluginInstanceIds = void 0;
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
|
-
const
|
|
11
|
+
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
// It is forbidden to have 2 plugins of the same name sharing the same id
|
|
13
13
|
// this is required to support multi-instance plugins without conflict
|
|
14
14
|
function ensureUniquePluginInstanceIds(plugins) {
|
|
15
15
|
const pluginsByName = (0, lodash_1.groupBy)(plugins, (p) => p.name);
|
|
16
16
|
Object.entries(pluginsByName).forEach(([pluginName, pluginInstances]) => {
|
|
17
|
-
const pluginInstancesById = (0, lodash_1.groupBy)(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a :
|
|
17
|
+
const pluginInstancesById = (0, lodash_1.groupBy)(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; });
|
|
18
18
|
Object.entries(pluginInstancesById).forEach(([pluginId, pluginInstancesWithId]) => {
|
|
19
19
|
if (pluginInstancesWithId.length !== 1) {
|
|
20
|
-
throw new Error(`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with ID "${pluginId}".\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.${pluginId ===
|
|
21
|
-
? `\n\nThe plugin ID is "${
|
|
20
|
+
throw new Error(`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with ID "${pluginId}".\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.${pluginId === utils_1.DEFAULT_PLUGIN_ID
|
|
21
|
+
? `\n\nThe plugin ID is "${utils_1.DEFAULT_PLUGIN_ID}" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances).`
|
|
22
22
|
: ''}`);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
-
const
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
const alias_1 = (0, tslib_1.__importStar)(require("./alias"));
|
|
14
14
|
const ThemeFallbackDir = path_1.default.resolve(__dirname, '../../client/theme-fallback');
|
|
15
15
|
function loadThemeAliases(themePaths, userThemePaths) {
|
|
@@ -40,7 +40,7 @@ function loadPluginsThemeAliases({ siteDir, plugins, }) {
|
|
|
40
40
|
const pluginThemes = plugins
|
|
41
41
|
.map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
|
|
42
42
|
.filter((x) => Boolean(x));
|
|
43
|
-
const userTheme = path_1.default.resolve(siteDir,
|
|
43
|
+
const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
|
|
44
44
|
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
45
45
|
}
|
|
46
46
|
exports.loadPluginsThemeAliases = loadPluginsThemeAliases;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
1
7
|
import { TranslationFileContent, TranslationFile, TranslationMessage, InitializedPlugin } from '@docusaurus/types';
|
|
2
8
|
export declare type WriteTranslationsOptions = {
|
|
3
9
|
override?: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = exports.getCodeTranslationsFilePath = exports.getTranslationsLocaleDirPath = exports.getTranslationsDirPath = exports.writeTranslationFileContent = exports.readTranslationFileContent = exports.ensureTranslationFileContent = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
2
|
/**
|
|
6
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
4
|
*
|
|
8
5
|
* This source code is licensed under the MIT license found in the
|
|
9
6
|
* LICENSE file in the root directory of this source tree.
|
|
10
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = exports.getCodeTranslationsFilePath = exports.getTranslationsLocaleDirPath = exports.getTranslationsDirPath = exports.writeTranslationFileContent = exports.readTranslationFileContent = exports.ensureTranslationFileContent = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
12
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
1
7
|
import { TransformOptions } from '@babel/core';
|
|
2
8
|
import { InitializedPlugin, TranslationFileContent, TranslationMessage } from '@docusaurus/types';
|
|
3
9
|
export declare function globSourceCodeFilePaths(dirPaths: string[]): Promise<string[]>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
2
|
/**
|
|
6
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
4
|
*
|
|
8
5
|
* This source code is licensed under the MIT license found in the
|
|
9
6
|
* LICENSE file in the root directory of this source tree.
|
|
10
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.extractSourceCodeFileTranslations = exports.extractAllSourceCodeFileTranslations = exports.extractSiteSourceCodeTranslations = exports.globSourceCodeFilePaths = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
12
|
const traverse_1 = (0, tslib_1.__importDefault)(require("@babel/traverse"));
|
|
13
13
|
const generator_1 = (0, tslib_1.__importDefault)(require("@babel/generator"));
|
|
14
14
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
15
15
|
const core_1 = require("@babel/core");
|
|
16
16
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const utils_1 = require("@docusaurus/utils");
|
|
18
|
+
const utils_2 = require("../utils");
|
|
19
19
|
// We only support extracting source code translations from these kind of files
|
|
20
20
|
const TranslatableSourceCodeExtension = new Set([
|
|
21
21
|
'.js',
|
|
@@ -31,7 +31,7 @@ function isTranslatableSourceCodePath(filePath) {
|
|
|
31
31
|
return TranslatableSourceCodeExtension.has(path_1.default.extname(filePath));
|
|
32
32
|
}
|
|
33
33
|
function getSiteSourceCodeFilePaths(siteDir) {
|
|
34
|
-
return [path_1.default.join(siteDir,
|
|
34
|
+
return [path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
|
|
35
35
|
}
|
|
36
36
|
function getPluginSourceCodeFilePaths(plugin) {
|
|
37
37
|
var _a, _b, _c;
|
|
@@ -47,7 +47,7 @@ function getPluginSourceCodeFilePaths(plugin) {
|
|
|
47
47
|
return codePaths;
|
|
48
48
|
}
|
|
49
49
|
async function globSourceCodeFilePaths(dirPaths) {
|
|
50
|
-
const filePaths = await (0,
|
|
50
|
+
const filePaths = await (0, utils_2.safeGlobby)(dirPaths);
|
|
51
51
|
return filePaths.filter(isTranslatableSourceCodePath);
|
|
52
52
|
}
|
|
53
53
|
exports.globSourceCodeFilePaths = globSourceCodeFilePaths;
|
package/lib/webpack/base.js
CHANGED
|
@@ -53,7 +53,7 @@ function createBaseConfig(props, isServer, minify = true) {
|
|
|
53
53
|
const isProd = process.env.NODE_ENV === 'production';
|
|
54
54
|
const minimizeEnabled = minify && isProd && !isServer;
|
|
55
55
|
const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
|
|
56
|
-
const fileLoaderUtils = (0,
|
|
56
|
+
const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
|
|
57
57
|
const name = isServer ? 'server' : 'client';
|
|
58
58
|
const mode = isProd ? 'production' : 'development';
|
|
59
59
|
const themeAliases = (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
2
|
/**
|
|
5
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
4
|
*
|
|
7
5
|
* This source code is licensed under the MIT license found in the
|
|
8
6
|
* LICENSE file in the root directory of this source tree.
|
|
9
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
10
|
const webpackbar_1 = (0, tslib_1.__importDefault)(require("webpackbar"));
|
|
11
11
|
const formatWebpackMessages_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/formatWebpackMessages"));
|
|
12
12
|
function showError(arr) {
|
package/lib/webpack/server.js
CHANGED
|
@@ -12,7 +12,7 @@ const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
|
|
|
12
12
|
const base_1 = require("./base");
|
|
13
13
|
const WaitPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/WaitPlugin"));
|
|
14
14
|
const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
|
|
15
|
-
const
|
|
15
|
+
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
// Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
|
|
17
17
|
const static_site_generator_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("@slorber/static-site-generator-webpack-plugin"));
|
|
18
18
|
function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
@@ -26,7 +26,7 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
|
26
26
|
return ssgPath;
|
|
27
27
|
});
|
|
28
28
|
const serverConfig = (0, webpack_merge_1.default)(config, {
|
|
29
|
-
target: `node${
|
|
29
|
+
target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
|
|
30
30
|
entry: {
|
|
31
31
|
main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
|
|
32
32
|
},
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -32,30 +32,8 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
|
|
|
32
32
|
export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
|
|
33
33
|
export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
|
|
34
34
|
export declare function compile(config: Configuration[]): Promise<void>;
|
|
35
|
-
declare type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
|
|
36
|
-
declare type FileLoaderUtils = {
|
|
37
|
-
loaders: {
|
|
38
|
-
file: (options: {
|
|
39
|
-
folder: AssetFolder;
|
|
40
|
-
}) => RuleSetRule;
|
|
41
|
-
url: (options: {
|
|
42
|
-
folder: AssetFolder;
|
|
43
|
-
}) => RuleSetRule;
|
|
44
|
-
inlineMarkdownImageFileLoader: string;
|
|
45
|
-
inlineMarkdownLinkFileLoader: string;
|
|
46
|
-
};
|
|
47
|
-
rules: {
|
|
48
|
-
images: () => RuleSetRule;
|
|
49
|
-
fonts: () => RuleSetRule;
|
|
50
|
-
media: () => RuleSetRule;
|
|
51
|
-
svg: () => RuleSetRule;
|
|
52
|
-
otherAssets: () => RuleSetRule;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export declare function getFileLoaderUtils(): FileLoaderUtils;
|
|
56
35
|
export declare function getHttpsConfig(): boolean | {
|
|
57
36
|
cert: Buffer;
|
|
58
37
|
key: Buffer;
|
|
59
38
|
};
|
|
60
39
|
export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
|
|
61
|
-
export {};
|