@docusaurus/core 0.0.0-4797 → 0.0.0-4800
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/commands/build.d.ts +1 -1
- package/lib/commands/build.js +6 -3
- package/lib/commands/clear.d.ts +1 -1
- package/lib/commands/clear.js +2 -1
- package/lib/commands/commandUtils.js +2 -3
- package/lib/commands/deploy.d.ts +1 -1
- package/lib/commands/deploy.js +6 -4
- package/lib/commands/external.d.ts +1 -1
- package/lib/commands/external.js +5 -6
- package/lib/commands/serve.d.ts +1 -1
- package/lib/commands/serve.js +6 -5
- package/lib/commands/start.d.ts +1 -1
- package/lib/commands/start.js +4 -2
- package/lib/commands/swizzle/common.d.ts +1 -2
- package/lib/commands/swizzle/context.js +6 -10
- package/lib/commands/swizzle/index.d.ts +1 -1
- package/lib/commands/swizzle/index.js +2 -1
- package/lib/commands/writeHeadingIds.d.ts +1 -1
- package/lib/commands/writeHeadingIds.js +5 -8
- package/lib/commands/writeTranslations.d.ts +1 -1
- package/lib/commands/writeTranslations.js +6 -8
- package/lib/index.d.ts +9 -10
- package/lib/index.js +18 -19
- package/lib/server/choosePort.d.ts +12 -0
- package/lib/{choosePort.js → server/choosePort.js} +8 -10
- package/lib/server/{client-modules/index.d.ts → clientModules.d.ts} +5 -1
- package/lib/server/{client-modules/index.js → clientModules.js} +6 -1
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +11 -6
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +2 -11
- package/lib/server/i18n.js +1 -18
- package/lib/server/index.d.ts +26 -11
- package/lib/server/index.js +40 -201
- package/lib/server/plugins/configs.d.ts +14 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +6 -6
- package/lib/server/plugins/index.js +29 -64
- package/lib/server/plugins/init.d.ts +6 -19
- package/lib/server/plugins/init.js +14 -65
- package/lib/server/{moduleShorthand.d.ts → plugins/moduleShorthand.d.ts} +0 -0
- package/lib/server/{moduleShorthand.js → plugins/moduleShorthand.js} +0 -0
- package/lib/server/plugins/pluginIds.d.ts +4 -0
- package/lib/server/plugins/pluginIds.js +4 -2
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/{presets/index.js → plugins/presets.js} +9 -4
- package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +2 -1
- package/lib/server/plugins/routeConfig.js +53 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +112 -0
- package/lib/server/routes.d.ts +3 -2
- package/lib/server/routes.js +50 -24
- package/lib/server/{versions/index.d.ts → siteMetadata.d.ts} +5 -2
- package/lib/server/{versions/index.js → siteMetadata.js} +36 -3
- package/lib/server/translations/translations.js +1 -4
- package/lib/webpack/aliases/index.d.ts +29 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +0 -3
- package/lib/webpack/base.js +4 -21
- package/package.json +10 -11
- package/lib/choosePort.d.ts +0 -11
- package/lib/server/duplicateRoutes.d.ts +0 -8
- package/lib/server/duplicateRoutes.js +0 -42
- package/lib/server/html-tags/htmlTags.d.ts +0 -7
- package/lib/server/html-tags/htmlTags.js +0 -38
- package/lib/server/html-tags/index.d.ts +0 -8
- package/lib/server/html-tags/index.js +0 -42
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/themes/alias.d.ts +0 -9
- package/lib/server/themes/alias.js +0 -50
- package/lib/server/themes/index.d.ts +0 -12
- package/lib/server/themes/index.js +0 -47
package/lib/commands/build.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { BuildCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export declare function build(siteDir: string, cliOptions?: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
|
package/lib/commands/build.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.build = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
11
12
|
const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
|
|
@@ -46,7 +47,8 @@ forceTerminate = true) {
|
|
|
46
47
|
throw err;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
const context = await (0, server_1.loadContext)(
|
|
50
|
+
const context = await (0, server_1.loadContext)({
|
|
51
|
+
siteDir,
|
|
50
52
|
customOutDir: cliOptions.outDir,
|
|
51
53
|
customConfigFilePath: cliOptions.config,
|
|
52
54
|
locale: cliOptions.locale,
|
|
@@ -73,12 +75,13 @@ forceTerminate = true) {
|
|
|
73
75
|
});
|
|
74
76
|
return results[0];
|
|
75
77
|
}
|
|
76
|
-
exports.
|
|
78
|
+
exports.build = build;
|
|
77
79
|
async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
|
|
78
80
|
process.env.BABEL_ENV = 'production';
|
|
79
81
|
process.env.NODE_ENV = 'production';
|
|
80
82
|
logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
|
|
81
|
-
const props = await (0, server_1.load)(
|
|
83
|
+
const props = await (0, server_1.load)({
|
|
84
|
+
siteDir,
|
|
82
85
|
customOutDir: cliOptions.outDir,
|
|
83
86
|
customConfigFilePath: cliOptions.config,
|
|
84
87
|
locale,
|
package/lib/commands/clear.d.ts
CHANGED
package/lib/commands/clear.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.clear = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -40,4 +41,4 @@ async function clear(siteDir) {
|
|
|
40
41
|
}));
|
|
41
42
|
return Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
|
|
42
43
|
}
|
|
43
|
-
exports.
|
|
44
|
+
exports.clear = clear;
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getCLIOptionPort = exports.getCLIOptionHost = void 0;
|
|
10
|
-
const
|
|
11
|
-
const choosePort_1 = tslib_1.__importDefault(require("../choosePort"));
|
|
10
|
+
const choosePort_1 = require("../server/choosePort");
|
|
12
11
|
const utils_1 = require("@docusaurus/utils");
|
|
13
12
|
function getCLIOptionHost(hostOption) {
|
|
14
13
|
return hostOption ?? 'localhost';
|
|
@@ -16,6 +15,6 @@ function getCLIOptionHost(hostOption) {
|
|
|
16
15
|
exports.getCLIOptionHost = getCLIOptionHost;
|
|
17
16
|
async function getCLIOptionPort(portOption, host) {
|
|
18
17
|
const basePort = portOption ? parseInt(portOption, 10) : utils_1.DEFAULT_PORT;
|
|
19
|
-
return (0, choosePort_1.
|
|
18
|
+
return (0, choosePort_1.choosePort)(host, basePort);
|
|
20
19
|
}
|
|
21
20
|
exports.getCLIOptionPort = getCLIOptionPort;
|
package/lib/commands/deploy.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { BuildCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export declare function deploy(siteDir: string, cliOptions?: Partial<BuildCLIOptions>): Promise<void>;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.deploy = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
12
|
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
|
|
12
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
14
|
const utils_1 = require("@docusaurus/utils");
|
|
14
15
|
const server_1 = require("../server");
|
|
15
|
-
const build_1 =
|
|
16
|
+
const build_1 = require("./build");
|
|
16
17
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
17
18
|
const os_1 = tslib_1.__importDefault(require("os"));
|
|
18
19
|
// GIT_PASS env variable should not appear in logs
|
|
@@ -34,7 +35,8 @@ function shellExecLog(cmd) {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
async function deploy(siteDir, cliOptions = {}) {
|
|
37
|
-
const { outDir, siteConfig, siteConfigPath } = await (0, server_1.loadContext)(
|
|
38
|
+
const { outDir, siteConfig, siteConfigPath } = await (0, server_1.loadContext)({
|
|
39
|
+
siteDir,
|
|
38
40
|
customConfigFilePath: cliOptions.config,
|
|
39
41
|
customOutDir: cliOptions.outDir,
|
|
40
42
|
});
|
|
@@ -172,7 +174,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
172
174
|
if (!cliOptions.skipBuild) {
|
|
173
175
|
// Build site, then push to deploymentBranch branch of specified repo.
|
|
174
176
|
try {
|
|
175
|
-
await runDeploy(await (0, build_1.
|
|
177
|
+
await runDeploy(await (0, build_1.build)(siteDir, cliOptions, false));
|
|
176
178
|
}
|
|
177
179
|
catch (err) {
|
|
178
180
|
logger_1.default.error('Deployment of the build output failed.');
|
|
@@ -184,4 +186,4 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
184
186
|
await runDeploy(outDir);
|
|
185
187
|
}
|
|
186
188
|
}
|
|
187
|
-
exports.
|
|
189
|
+
exports.deploy = deploy;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { CommanderStatic } from 'commander';
|
|
8
|
-
export
|
|
8
|
+
export declare function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
|
package/lib/commands/external.js
CHANGED
|
@@ -6,16 +6,15 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
|
|
9
|
+
exports.externalCommand = void 0;
|
|
10
10
|
const server_1 = require("../server");
|
|
11
|
-
const init_1 =
|
|
11
|
+
const init_1 = require("../server/plugins/init");
|
|
12
12
|
async function externalCommand(cli, siteDir) {
|
|
13
|
-
const context = await (0, server_1.loadContext)(siteDir);
|
|
14
|
-
const
|
|
15
|
-
const plugins = await (0, init_1.default)({ pluginConfigs, context });
|
|
13
|
+
const context = await (0, server_1.loadContext)({ siteDir });
|
|
14
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
16
15
|
// Plugin Lifecycle - extendCli.
|
|
17
16
|
plugins.forEach((plugin) => {
|
|
18
17
|
plugin.extendCli?.(cli);
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
|
-
exports.
|
|
20
|
+
exports.externalCommand = externalCommand;
|
package/lib/commands/serve.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { ServeCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export declare function serve(siteDir: string, cliOptions: ServeCLIOptions): Promise<void>;
|
package/lib/commands/serve.js
CHANGED
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.serve = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const http_1 = tslib_1.__importDefault(require("http"));
|
|
11
12
|
const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
|
|
12
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
|
-
const
|
|
15
|
-
const build_1 =
|
|
15
|
+
const config_1 = require("../server/config");
|
|
16
|
+
const build_1 = require("./build");
|
|
16
17
|
const commandUtils_1 = require("./commandUtils");
|
|
17
18
|
async function serve(siteDir, cliOptions) {
|
|
18
19
|
let dir = path_1.default.resolve(siteDir, cliOptions.dir);
|
|
19
20
|
if (cliOptions.build) {
|
|
20
|
-
dir = await (0, build_1.
|
|
21
|
+
dir = await (0, build_1.build)(siteDir, {
|
|
21
22
|
config: cliOptions.config,
|
|
22
23
|
outDir: dir,
|
|
23
24
|
}, false);
|
|
@@ -27,7 +28,7 @@ async function serve(siteDir, cliOptions) {
|
|
|
27
28
|
if (port === null) {
|
|
28
29
|
process.exit();
|
|
29
30
|
}
|
|
30
|
-
const { siteConfig: { baseUrl, trailingSlash }, } = await (0,
|
|
31
|
+
const { siteConfig: { baseUrl, trailingSlash }, } = await (0, config_1.loadSiteConfig)({
|
|
31
32
|
siteDir,
|
|
32
33
|
customConfigFilePath: cliOptions.config,
|
|
33
34
|
});
|
|
@@ -54,4 +55,4 @@ async function serve(siteDir, cliOptions) {
|
|
|
54
55
|
logger_1.default.success `Serving path=${cliOptions.dir} directory at url=${servingUrl + baseUrl}.`;
|
|
55
56
|
server.listen(port);
|
|
56
57
|
}
|
|
57
|
-
exports.
|
|
58
|
+
exports.serve = serve;
|
package/lib/commands/start.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { StartCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export declare function start(siteDir: string, cliOptions: Partial<StartCLIOptions>): Promise<void>;
|
package/lib/commands/start.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.start = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const utils_1 = require("@docusaurus/utils");
|
|
11
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -29,7 +30,8 @@ async function start(siteDir, cliOptions) {
|
|
|
29
30
|
process.env.BABEL_ENV = 'development';
|
|
30
31
|
logger_1.default.info('Starting the development server...');
|
|
31
32
|
function loadSite() {
|
|
32
|
-
return (0, server_1.load)(
|
|
33
|
+
return (0, server_1.load)({
|
|
34
|
+
siteDir,
|
|
33
35
|
customConfigFilePath: cliOptions.config,
|
|
34
36
|
locale: cliOptions.locale,
|
|
35
37
|
localizePath: undefined, // should this be configurable?
|
|
@@ -198,4 +200,4 @@ async function start(siteDir, cliOptions) {
|
|
|
198
200
|
});
|
|
199
201
|
});
|
|
200
202
|
}
|
|
201
|
-
exports.
|
|
203
|
+
exports.start = start;
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type { InitializedPlugin, SwizzleAction, SwizzleActionStatus } from '@docusaurus/types';
|
|
8
|
-
import type { NormalizedPluginConfig } from '../../server/plugins/init';
|
|
7
|
+
import type { InitializedPlugin, SwizzleAction, SwizzleActionStatus, NormalizedPluginConfig } from '@docusaurus/types';
|
|
9
8
|
export declare const SwizzleActions: SwizzleAction[];
|
|
10
9
|
export declare const SwizzleActionsStatuses: SwizzleActionStatus[];
|
|
11
10
|
export declare const PartiallySafeHint: string;
|
|
@@ -7,20 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.initSwizzleContext = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
10
|
const server_1 = require("../../server");
|
|
12
|
-
const init_1 =
|
|
11
|
+
const init_1 = require("../../server/plugins/init");
|
|
12
|
+
const configs_1 = require("../../server/plugins/configs");
|
|
13
13
|
async function initSwizzleContext(siteDir) {
|
|
14
|
-
const context = await (0, server_1.loadContext)(siteDir);
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
pluginConfigs,
|
|
18
|
-
context,
|
|
19
|
-
});
|
|
20
|
-
const pluginsNormalized = await (0, init_1.normalizePluginConfigs)(pluginConfigs, context.siteConfigPath);
|
|
14
|
+
const context = await (0, server_1.loadContext)({ siteDir });
|
|
15
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
16
|
+
const pluginConfigs = await (0, configs_1.loadPluginConfigs)(context);
|
|
21
17
|
return {
|
|
22
18
|
plugins: plugins.map((plugin, pluginIndex) => ({
|
|
23
|
-
plugin:
|
|
19
|
+
plugin: pluginConfigs[pluginIndex],
|
|
24
20
|
instance: plugin,
|
|
25
21
|
})),
|
|
26
22
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { SwizzleOptions } from './common';
|
|
8
|
-
export
|
|
8
|
+
export declare function swizzle(siteDir: string, themeNameParam: string | undefined, componentNameParam: string | undefined, optionsParam: Partial<SwizzleOptions>): Promise<void>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.swizzle = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
11
12
|
const themes_1 = require("./themes");
|
|
@@ -112,4 +113,4 @@ Ejected name=${componentName} from name=${themeName} to path=${result.createdFil
|
|
|
112
113
|
await executeAction();
|
|
113
114
|
return process.exit(0);
|
|
114
115
|
}
|
|
115
|
-
exports.
|
|
116
|
+
exports.swizzle = swizzle;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type WriteHeadingIDOptions } from '@docusaurus/utils';
|
|
8
|
-
export
|
|
8
|
+
export declare function writeHeadingIds(siteDir: string, files?: string[], options?: WriteHeadingIDOptions): Promise<void>;
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.writeHeadingIds = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
13
|
const utils_1 = require("@docusaurus/utils");
|
|
13
14
|
const server_1 = require("../server");
|
|
14
|
-
const init_1 =
|
|
15
|
+
const init_1 = require("../server/plugins/init");
|
|
15
16
|
const utils_2 = require("../server/utils");
|
|
16
17
|
async function transformMarkdownFile(filepath, options) {
|
|
17
18
|
const content = await fs_extra_1.default.readFile(filepath, 'utf8');
|
|
@@ -29,12 +30,8 @@ async function transformMarkdownFile(filepath, options) {
|
|
|
29
30
|
* transformed
|
|
30
31
|
*/
|
|
31
32
|
async function getPathsToWatch(siteDir) {
|
|
32
|
-
const context = await (0, server_1.loadContext)(siteDir);
|
|
33
|
-
const
|
|
34
|
-
const plugins = await (0, init_1.default)({
|
|
35
|
-
pluginConfigs,
|
|
36
|
-
context,
|
|
37
|
-
});
|
|
33
|
+
const context = await (0, server_1.loadContext)({ siteDir });
|
|
34
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
38
35
|
return plugins.flatMap((plugin) => plugin?.getPathsToWatch?.() ?? []);
|
|
39
36
|
}
|
|
40
37
|
async function writeHeadingIds(siteDir, files, options) {
|
|
@@ -50,4 +47,4 @@ async function writeHeadingIds(siteDir, files, options) {
|
|
|
50
47
|
logger_1.default.warn `number=${markdownFiles.length} Markdown files already have explicit heading IDs. If you intend to overwrite the existing heading IDs, use the code=${'--overwrite'} option.`;
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
|
-
exports.
|
|
50
|
+
exports.writeHeadingIds = writeHeadingIds;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ConfigOptions } from '@docusaurus/types';
|
|
8
8
|
import { type WriteTranslationsOptions } from '../server/translations/translations';
|
|
9
|
-
export
|
|
9
|
+
export declare function writeTranslations(siteDir: string, options: WriteTranslationsOptions & ConfigOptions & {
|
|
10
10
|
locale?: string;
|
|
11
11
|
}): Promise<void>;
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.writeTranslations = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
12
|
const server_1 = require("../server");
|
|
12
|
-
const init_1 =
|
|
13
|
+
const init_1 = require("../server/plugins/init");
|
|
13
14
|
const translations_1 = require("../server/translations/translations");
|
|
14
15
|
const translationsExtractor_1 = require("../server/translations/translationsExtractor");
|
|
15
16
|
const utils_1 = require("../webpack/utils");
|
|
@@ -47,15 +48,12 @@ async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
async function writeTranslations(siteDir, options) {
|
|
50
|
-
const context = await (0, server_1.loadContext)(
|
|
51
|
+
const context = await (0, server_1.loadContext)({
|
|
52
|
+
siteDir,
|
|
51
53
|
customConfigFilePath: options.config,
|
|
52
54
|
locale: options.locale,
|
|
53
55
|
});
|
|
54
|
-
const
|
|
55
|
-
const plugins = await (0, init_1.default)({
|
|
56
|
-
pluginConfigs,
|
|
57
|
-
context,
|
|
58
|
-
});
|
|
56
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
59
57
|
const locale = options.locale ?? context.i18n.defaultLocale;
|
|
60
58
|
if (!context.i18n.locales.includes(locale)) {
|
|
61
59
|
throw new Error(`Can't write-translation for locale "${locale}" that is not in the locale configuration file.
|
|
@@ -76,4 +74,4 @@ Available locales are: ${context.i18n.locales.join(',')}.`);
|
|
|
76
74
|
await writePluginTranslationFiles({ siteDir, plugin, locale, options });
|
|
77
75
|
}));
|
|
78
76
|
}
|
|
79
|
-
exports.
|
|
77
|
+
exports.writeTranslations = writeTranslations;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export { build, clear, deploy, externalCommand, serve, start, swizzle, writeHeadingIds, writeTranslations, };
|
|
7
|
+
export { build } from './commands/build';
|
|
8
|
+
export { clear } from './commands/clear';
|
|
9
|
+
export { deploy } from './commands/deploy';
|
|
10
|
+
export { externalCommand } from './commands/external';
|
|
11
|
+
export { serve } from './commands/serve';
|
|
12
|
+
export { start } from './commands/start';
|
|
13
|
+
export { swizzle } from './commands/swizzle';
|
|
14
|
+
export { writeHeadingIds } from './commands/writeHeadingIds';
|
|
15
|
+
export { writeTranslations } from './commands/writeTranslations';
|
package/lib/index.js
CHANGED
|
@@ -7,22 +7,21 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.writeTranslations = exports.writeHeadingIds = exports.swizzle = exports.start = exports.serve = exports.externalCommand = exports.deploy = exports.clear = exports.build = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.writeTranslations = writeTranslations_1.default;
|
|
10
|
+
var build_1 = require("./commands/build");
|
|
11
|
+
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
|
|
12
|
+
var clear_1 = require("./commands/clear");
|
|
13
|
+
Object.defineProperty(exports, "clear", { enumerable: true, get: function () { return clear_1.clear; } });
|
|
14
|
+
var deploy_1 = require("./commands/deploy");
|
|
15
|
+
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
|
|
16
|
+
var external_1 = require("./commands/external");
|
|
17
|
+
Object.defineProperty(exports, "externalCommand", { enumerable: true, get: function () { return external_1.externalCommand; } });
|
|
18
|
+
var serve_1 = require("./commands/serve");
|
|
19
|
+
Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return serve_1.serve; } });
|
|
20
|
+
var start_1 = require("./commands/start");
|
|
21
|
+
Object.defineProperty(exports, "start", { enumerable: true, get: function () { return start_1.start; } });
|
|
22
|
+
var swizzle_1 = require("./commands/swizzle");
|
|
23
|
+
Object.defineProperty(exports, "swizzle", { enumerable: true, get: function () { return swizzle_1.swizzle; } });
|
|
24
|
+
var writeHeadingIds_1 = require("./commands/writeHeadingIds");
|
|
25
|
+
Object.defineProperty(exports, "writeHeadingIds", { enumerable: true, get: function () { return writeHeadingIds_1.writeHeadingIds; } });
|
|
26
|
+
var writeTranslations_1 = require("./commands/writeTranslations");
|
|
27
|
+
Object.defineProperty(exports, "writeTranslations", { enumerable: true, get: function () { return writeTranslations_1.writeTranslations; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Detects if program is running on port, and prompts user to choose another if
|
|
9
|
+
* port is already being used. This feature was heavily inspired by
|
|
10
|
+
* create-react-app and uses many of the same utility functions to implement it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function choosePort(host: string, defaultPort: number): Promise<number | null>;
|
|
@@ -6,17 +6,12 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.choosePort = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
|
-
/**
|
|
11
|
-
* This feature was heavily inspired by create-react-app and
|
|
12
|
-
* uses many of the same utility functions to implement it.
|
|
13
|
-
*/
|
|
14
11
|
const child_process_1 = require("child_process");
|
|
15
12
|
const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
|
|
16
|
-
const is_root_1 = tslib_1.__importDefault(require("is-root"));
|
|
17
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
18
14
|
const prompts_1 = tslib_1.__importDefault(require("prompts"));
|
|
19
|
-
const isInteractive = process.stdout.isTTY;
|
|
20
15
|
const execOptions = {
|
|
21
16
|
encoding: 'utf8',
|
|
22
17
|
stdio: [
|
|
@@ -57,8 +52,9 @@ function getProcessForPort(port) {
|
|
|
57
52
|
}
|
|
58
53
|
}
|
|
59
54
|
/**
|
|
60
|
-
* Detects if program is running on port and prompts user
|
|
61
|
-
*
|
|
55
|
+
* Detects if program is running on port, and prompts user to choose another if
|
|
56
|
+
* port is already being used. This feature was heavily inspired by
|
|
57
|
+
* create-react-app and uses many of the same utility functions to implement it.
|
|
62
58
|
*/
|
|
63
59
|
async function choosePort(host, defaultPort) {
|
|
64
60
|
try {
|
|
@@ -66,7 +62,9 @@ async function choosePort(host, defaultPort) {
|
|
|
66
62
|
if (port === defaultPort) {
|
|
67
63
|
return port;
|
|
68
64
|
}
|
|
69
|
-
const
|
|
65
|
+
const isRoot = process.getuid?.() === 0;
|
|
66
|
+
const isInteractive = process.stdout.isTTY;
|
|
67
|
+
const message = process.platform !== 'win32' && defaultPort < 1024 && !isRoot
|
|
70
68
|
? `Admin permissions are required to run a server on a port below 1024.`
|
|
71
69
|
: `Something is already running on port ${defaultPort}.`;
|
|
72
70
|
if (!isInteractive) {
|
|
@@ -90,4 +88,4 @@ Would you like to run the app on another port instead?`),
|
|
|
90
88
|
throw err;
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
exports.
|
|
91
|
+
exports.choosePort = choosePort;
|
|
@@ -5,4 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { LoadedPlugin } from '@docusaurus/types';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Runs the `getClientModules` lifecycle. The returned file paths are all
|
|
10
|
+
* absolute.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadClientModules(plugins: LoadedPlugin[]): string[];
|
|
@@ -6,10 +6,15 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadClientModules = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
/**
|
|
13
|
+
* Runs the `getClientModules` lifecycle. The returned file paths are all
|
|
14
|
+
* absolute.
|
|
15
|
+
*/
|
|
11
16
|
function loadClientModules(plugins) {
|
|
12
17
|
return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) => path_1.default.resolve(plugin.path, p)) ??
|
|
13
18
|
[]);
|
|
14
19
|
}
|
|
15
|
-
exports.
|
|
20
|
+
exports.loadClientModules = loadClientModules;
|
package/lib/server/config.d.ts
CHANGED
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
export
|
|
7
|
+
import type { LoadContext } from '@docusaurus/types';
|
|
8
|
+
export declare function loadSiteConfig({ siteDir, customConfigFilePath, }: {
|
|
9
|
+
siteDir: string;
|
|
10
|
+
customConfigFilePath?: string;
|
|
11
|
+
}): Promise<Pick<LoadContext, 'siteConfig' | 'siteConfigPath'>>;
|
package/lib/server/config.js
CHANGED
|
@@ -6,18 +6,23 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadSiteConfig = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
13
|
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
12
15
|
const configValidation_1 = require("./configValidation");
|
|
13
|
-
async function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
17
|
+
const siteConfigPath = path_1.default.resolve(siteDir, customConfigFilePath ?? utils_1.DEFAULT_CONFIG_FILE_NAME);
|
|
18
|
+
if (!(await fs_extra_1.default.pathExists(siteConfigPath))) {
|
|
19
|
+
throw new Error(`Config file at "${siteConfigPath}" not found.`);
|
|
16
20
|
}
|
|
17
|
-
const importedConfig = (0, import_fresh_1.default)(
|
|
21
|
+
const importedConfig = (0, import_fresh_1.default)(siteConfigPath);
|
|
18
22
|
const loadedConfig = typeof importedConfig === 'function'
|
|
19
23
|
? await importedConfig()
|
|
20
24
|
: await importedConfig;
|
|
21
|
-
|
|
25
|
+
const siteConfig = (0, configValidation_1.validateConfig)(loadedConfig);
|
|
26
|
+
return { siteConfig, siteConfigPath };
|
|
22
27
|
}
|
|
23
|
-
exports.
|
|
28
|
+
exports.loadSiteConfig = loadSiteConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
*/
|
|
7
|
+
import type { Props, LoadedPlugin } from '@docusaurus/types';
|
|
8
|
+
/**
|
|
9
|
+
* Runs the `injectHtmlTags` lifecycle, and aggregates all plugins' tags into
|
|
10
|
+
* directly render-able HTML markup.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadHtmlTags(plugins: LoadedPlugin[]): Pick<Props, 'headTags' | 'preBodyTags' | 'postBodyTags'>;
|