@docusaurus/core 0.0.0-4943 → 0.0.0-4946

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.
@@ -4,5 +4,9 @@
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 { BuildCLIOptions } from '@docusaurus/types';
7
+ import { type LoadContextOptions } from '../server';
8
+ export declare type BuildCLIOptions = Pick<LoadContextOptions, 'config' | 'locale' | 'outDir'> & {
9
+ bundleAnalyzer?: boolean;
10
+ minify?: boolean;
11
+ };
8
12
  export declare function build(siteDir: string, cliOptions: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
@@ -49,8 +49,8 @@ forceTerminate = true) {
49
49
  }
50
50
  const context = await (0, server_1.loadContext)({
51
51
  siteDir,
52
- customOutDir: cliOptions.outDir,
53
- customConfigFilePath: cliOptions.config,
52
+ outDir: cliOptions.outDir,
53
+ config: cliOptions.config,
54
54
  locale: cliOptions.locale,
55
55
  localizePath: cliOptions.locale ? false : undefined,
56
56
  });
@@ -82,8 +82,8 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
82
82
  logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
83
83
  const props = await (0, server_1.load)({
84
84
  siteDir,
85
- customOutDir: cliOptions.outDir,
86
- customConfigFilePath: cliOptions.config,
85
+ outDir: cliOptions.outDir,
86
+ config: cliOptions.config,
87
87
  locale,
88
88
  localizePath: cliOptions.locale ? false : undefined,
89
89
  });
@@ -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 { BuildCLIOptions } from '@docusaurus/types';
8
- export declare function deploy(siteDir: string, cliOptions: Partial<BuildCLIOptions>): Promise<void>;
7
+ import { type LoadContextOptions } from '../server';
8
+ export declare type DeployCLIOptions = Pick<LoadContextOptions, 'config' | 'locale' | 'outDir'> & {
9
+ skipBuild?: boolean;
10
+ };
11
+ export declare function deploy(siteDir: string, cliOptions: Partial<DeployCLIOptions>): Promise<void>;
@@ -37,8 +37,8 @@ function shellExecLog(cmd) {
37
37
  async function deploy(siteDir, cliOptions) {
38
38
  const { outDir, siteConfig, siteConfigPath } = await (0, server_1.loadContext)({
39
39
  siteDir,
40
- customConfigFilePath: cliOptions.config,
41
- customOutDir: cliOptions.outDir,
40
+ config: cliOptions.config,
41
+ outDir: cliOptions.outDir,
42
42
  });
43
43
  if (typeof siteConfig.trailingSlash === 'undefined') {
44
44
  logger_1.default.warn(`When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
@@ -4,5 +4,10 @@
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 { ServeCLIOptions } from '@docusaurus/types';
7
+ import type { LoadContextOptions } from '../server';
8
+ import { type HostPortOptions } from '../server/getHostPort';
9
+ export declare type ServeCLIOptions = HostPortOptions & Pick<LoadContextOptions, 'config'> & {
10
+ dir?: string;
11
+ build?: boolean;
12
+ };
8
13
  export declare function serve(siteDir: string, cliOptions: Partial<ServeCLIOptions>): Promise<void>;
@@ -14,7 +14,7 @@ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
14
  const path_1 = tslib_1.__importDefault(require("path"));
15
15
  const config_1 = require("../server/config");
16
16
  const build_1 = require("./build");
17
- const commandUtils_1 = require("./commandUtils");
17
+ const getHostPort_1 = require("../server/getHostPort");
18
18
  const utils_1 = require("@docusaurus/utils");
19
19
  async function serve(siteDir, cliOptions) {
20
20
  const buildDir = cliOptions.dir ?? utils_1.DEFAULT_BUILD_DIR_NAME;
@@ -25,8 +25,7 @@ async function serve(siteDir, cliOptions) {
25
25
  outDir: dir,
26
26
  }, false);
27
27
  }
28
- const host = (0, commandUtils_1.getCLIOptionHost)(cliOptions.host);
29
- const port = await (0, commandUtils_1.getCLIOptionPort)(cliOptions.port, host);
28
+ const { host, port } = await (0, getHostPort_1.getHostPort)(cliOptions);
30
29
  if (port === null) {
31
30
  process.exit();
32
31
  }
@@ -4,5 +4,11 @@
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 { StartCLIOptions } from '@docusaurus/types';
7
+ import { type LoadContextOptions } from '../server';
8
+ import { type HostPortOptions } from '../server/getHostPort';
9
+ export declare type StartCLIOptions = HostPortOptions & Pick<LoadContextOptions, 'locale' | 'config'> & {
10
+ hotOnly?: boolean;
11
+ open?: boolean;
12
+ poll?: boolean | number;
13
+ };
8
14
  export declare function start(siteDir: string, cliOptions: Partial<StartCLIOptions>): Promise<void>;
@@ -23,7 +23,7 @@ const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
23
23
  const server_1 = require("../server");
24
24
  const client_1 = tslib_1.__importDefault(require("../webpack/client"));
25
25
  const utils_2 = require("../webpack/utils");
26
- const commandUtils_1 = require("./commandUtils");
26
+ const getHostPort_1 = require("../server/getHostPort");
27
27
  const translations_1 = require("../server/translations/translations");
28
28
  async function start(siteDir, cliOptions) {
29
29
  process.env.NODE_ENV = 'development';
@@ -32,7 +32,7 @@ async function start(siteDir, cliOptions) {
32
32
  function loadSite() {
33
33
  return (0, server_1.load)({
34
34
  siteDir,
35
- customConfigFilePath: cliOptions.config,
35
+ config: cliOptions.config,
36
36
  locale: cliOptions.locale,
37
37
  localizePath: undefined, // Should this be configurable?
38
38
  });
@@ -40,8 +40,7 @@ async function start(siteDir, cliOptions) {
40
40
  // Process all related files as a prop.
41
41
  const props = await loadSite();
42
42
  const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
43
- const host = (0, commandUtils_1.getCLIOptionHost)(cliOptions.host);
44
- const port = await (0, commandUtils_1.getCLIOptionPort)(cliOptions.port, host);
43
+ const { host, port } = await (0, getHostPort_1.getHostPort)(cliOptions);
45
44
  if (port === null) {
46
45
  process.exit();
47
46
  }
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { SwizzleAction, SwizzleComponentConfig } from '@docusaurus/types';
8
- import type { SwizzleOptions } from './common';
8
+ import type { SwizzleCLIOptions } from './common';
9
9
  export declare const SwizzleActions: SwizzleAction[];
10
- export declare function getAction(componentConfig: SwizzleComponentConfig, options: Pick<SwizzleOptions, 'wrap' | 'eject'>): Promise<SwizzleAction>;
10
+ export declare function getAction(componentConfig: SwizzleComponentConfig, options: Pick<SwizzleCLIOptions, 'wrap' | 'eject'>): Promise<SwizzleAction>;
11
11
  export declare type ActionParams = {
12
12
  siteDir: string;
13
13
  themePath: string;
@@ -4,7 +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 { InitializedPlugin, SwizzleAction, SwizzleActionStatus, NormalizedPluginConfig } from '@docusaurus/types';
7
+ import type { NormalizedPluginConfig } from '../../server/plugins/configs';
8
+ import type { InitializedPlugin, SwizzleAction, SwizzleActionStatus } from '@docusaurus/types';
8
9
  export declare const SwizzleActions: SwizzleAction[];
9
10
  export declare const SwizzleActionsStatuses: SwizzleActionStatus[];
10
11
  export declare const PartiallySafeHint: string;
@@ -20,13 +21,13 @@ export declare type SwizzlePlugin = {
20
21
  export declare type SwizzleContext = {
21
22
  plugins: SwizzlePlugin[];
22
23
  };
23
- export declare type SwizzleOptions = {
24
+ export declare type SwizzleCLIOptions = {
24
25
  typescript: boolean;
25
26
  danger: boolean;
26
27
  list: boolean;
27
28
  wrap: boolean;
28
29
  eject: boolean;
29
30
  };
30
- export declare function normalizeOptions(options: Partial<SwizzleOptions>): SwizzleOptions;
31
+ export declare function normalizeOptions(options: Partial<SwizzleCLIOptions>): SwizzleCLIOptions;
31
32
  export declare function findStringIgnoringCase(str: string, values: string[]): string | undefined;
32
33
  export declare function findClosestValue(str: string, values: string[], maxLevenshtein?: number): string | undefined;
@@ -4,5 +4,5 @@
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 { SwizzleOptions } from './common';
8
- export declare function swizzle(siteDir: string, themeNameParam: string | undefined, componentNameParam: string | undefined, optionsParam: Partial<SwizzleOptions>): Promise<void>;
7
+ import type { SwizzleCLIOptions } from './common';
8
+ export declare function swizzle(siteDir: string, themeNameParam: string | undefined, componentNameParam: string | undefined, optionsParam: Partial<SwizzleCLIOptions>): Promise<void>;
@@ -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 { ConfigOptions } from '@docusaurus/types';
7
+ import { type LoadContextOptions } from '../server';
8
8
  import { type WriteTranslationsOptions } from '../server/translations/translations';
9
- export declare function writeTranslations(siteDir: string, options: Partial<WriteTranslationsOptions & ConfigOptions & {
10
- locale?: string;
11
- }>): Promise<void>;
9
+ export declare type WriteTranslationsCLIOptions = Pick<LoadContextOptions, 'config' | 'locale'> & WriteTranslationsOptions;
10
+ export declare function writeTranslations(siteDir: string, options: Partial<WriteTranslationsCLIOptions>): Promise<void>;
@@ -50,7 +50,7 @@ async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }
50
50
  async function writeTranslations(siteDir, options) {
51
51
  const context = await (0, server_1.loadContext)({
52
52
  siteDir,
53
- customConfigFilePath: options.config,
53
+ config: options.config,
54
54
  locale: options.locale,
55
55
  });
56
56
  const plugins = await (0, init_1.initPlugins)(context);
@@ -0,0 +1,14 @@
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
+ export declare type HostPortOptions = {
8
+ host?: string;
9
+ port?: string;
10
+ };
11
+ export declare function getHostPort(options: HostPortOptions): Promise<{
12
+ host: string;
13
+ port: number | null;
14
+ }>;
@@ -6,11 +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
+ exports.getHostPort = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const child_process_1 = require("child_process");
12
12
  const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
13
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const utils_1 = require("@docusaurus/utils");
14
15
  const prompts_1 = tslib_1.__importDefault(require("prompts"));
15
16
  const execOptions = {
16
17
  encoding: 'utf8',
@@ -69,4 +70,10 @@ Would you like to run the app on another port instead?`),
69
70
  throw err;
70
71
  }
71
72
  }
72
- exports.choosePort = choosePort;
73
+ async function getHostPort(options) {
74
+ const host = options.host ?? 'localhost';
75
+ const basePort = options.port ? parseInt(options.port, 10) : utils_1.DEFAULT_PORT;
76
+ const port = await choosePort(host, basePort);
77
+ return { host, port };
78
+ }
79
+ exports.getHostPort = getHostPort;
@@ -8,10 +8,10 @@ import type { LoadContext, Props } from '@docusaurus/types';
8
8
  export declare type LoadContextOptions = {
9
9
  /** Usually the CWD; can be overridden with command argument. */
10
10
  siteDir: string;
11
- /** Can be customized with `--out-dir` option */
12
- customOutDir?: string;
13
- /** Can be customized with `--config` option */
14
- customConfigFilePath?: string;
11
+ /** Custom output directory. Can be customized with `--out-dir` option */
12
+ outDir?: string;
13
+ /** Custom config path. Can be customized with `--config` option */
14
+ config?: string;
15
15
  /** Default is `i18n.defaultLocale` */
16
16
  locale?: string;
17
17
  /**
@@ -26,7 +26,7 @@ const translations_1 = require("./translations/translations");
26
26
  * to plugin constructors.
27
27
  */
28
28
  async function loadContext(options) {
29
- const { siteDir, customOutDir, locale, customConfigFilePath } = options;
29
+ const { siteDir, outDir: baseOutDir = utils_1.DEFAULT_BUILD_DIR_NAME, locale, config: customConfigFilePath, } = options;
30
30
  const generatedFilesDir = path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
31
31
  const { siteConfig: initialSiteConfig, siteConfigPath } = await (0, config_1.loadSiteConfig)({
32
32
  siteDir,
@@ -40,7 +40,7 @@ async function loadContext(options) {
40
40
  pathType: 'url',
41
41
  });
42
42
  const outDir = (0, utils_1.localizePath)({
43
- path: path_1.default.resolve(siteDir, customOutDir ?? utils_1.DEFAULT_BUILD_DIR_NAME),
43
+ path: path_1.default.resolve(siteDir, baseOutDir),
44
44
  i18n,
45
45
  options,
46
46
  pathType: 'fs',
@@ -4,7 +4,43 @@
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 { LoadContext, NormalizedPluginConfig } from '@docusaurus/types';
7
+ import type { LoadContext, PluginModule, PluginOptions } from '@docusaurus/types';
8
+ declare type ImportedPluginModule = PluginModule & {
9
+ default?: PluginModule;
10
+ };
11
+ export declare type NormalizedPluginConfig = {
12
+ /**
13
+ * The default export of the plugin module, or alternatively, what's provided
14
+ * in the config file as inline plugins. Note that if a file is like:
15
+ *
16
+ * ```ts
17
+ * export default plugin() {...}
18
+ * export validateOptions() {...}
19
+ * ```
20
+ *
21
+ * Then the static methods may not exist here. `pluginModule.module` will
22
+ * always take priority.
23
+ */
24
+ plugin: PluginModule;
25
+ /** Options as they are provided in the config, not validated yet. */
26
+ options: PluginOptions;
27
+ /** Only available when a string is provided in config. */
28
+ pluginModule?: {
29
+ /**
30
+ * Raw module name as provided in the config. Shorthands have been resolved,
31
+ * so at least it's directly `require.resolve`able.
32
+ */
33
+ path: string;
34
+ /** Whatever gets imported with `require`. */
35
+ module: ImportedPluginModule;
36
+ };
37
+ /**
38
+ * Different from `pluginModule.path`, this one is always an absolute path,
39
+ * used to resolve relative paths returned from lifecycles. If it's an inline
40
+ * plugin, it will be path to the config file.
41
+ */
42
+ entryPath: string;
43
+ };
8
44
  /**
9
45
  * Reads the site config's `presets`, `themes`, and `plugins`, imports them, and
10
46
  * normalizes the return value. Plugin configs are ordered, mostly for theme
@@ -12,3 +48,4 @@ import type { LoadContext, NormalizedPluginConfig } from '@docusaurus/types';
12
48
  * are the lowest.
13
49
  */
14
50
  export declare function loadPluginConfigs(context: LoadContext): Promise<NormalizedPluginConfig[]>;
51
+ export {};
@@ -4,7 +4,13 @@
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 { ThemeAliases, LoadedPlugin } from '@docusaurus/types';
7
+ import type { LoadedPlugin } from '@docusaurus/types';
8
+ /**
9
+ * Aliases used for Webpack resolution (useful for implementing swizzling)
10
+ */
11
+ declare type ThemeAliases = {
12
+ [alias: string]: string;
13
+ };
8
14
  /**
9
15
  * Order of Webpack aliases is important because one alias can shadow another.
10
16
  * This ensures `@theme/NavbarItem` alias is after
@@ -25,3 +31,4 @@ export declare function loadThemeAliases({ siteDir, plugins, }: {
25
31
  * aliases instead.
26
32
  */
27
33
  export declare function loadDocusaurusAliases(): Promise<ThemeAliases>;
34
+ export {};
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-4943",
4
+ "version": "0.0.0-4946",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.9",
42
42
  "@babel/runtime-corejs3": "^7.17.9",
43
43
  "@babel/traverse": "^7.17.10",
44
- "@docusaurus/cssnano-preset": "0.0.0-4943",
45
- "@docusaurus/logger": "0.0.0-4943",
46
- "@docusaurus/mdx-loader": "0.0.0-4943",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4946",
45
+ "@docusaurus/logger": "0.0.0-4946",
46
+ "@docusaurus/mdx-loader": "0.0.0-4946",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4943",
49
- "@docusaurus/utils-common": "0.0.0-4943",
50
- "@docusaurus/utils-validation": "0.0.0-4943",
48
+ "@docusaurus/utils": "0.0.0-4946",
49
+ "@docusaurus/utils-common": "0.0.0-4946",
50
+ "@docusaurus/utils-validation": "0.0.0-4946",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.4",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.5",
@@ -104,8 +104,8 @@
104
104
  "webpackbar": "^5.0.2"
105
105
  },
106
106
  "devDependencies": {
107
- "@docusaurus/module-type-aliases": "0.0.0-4943",
108
- "@docusaurus/types": "0.0.0-4943",
107
+ "@docusaurus/module-type-aliases": "0.0.0-4946",
108
+ "@docusaurus/types": "0.0.0-4946",
109
109
  "@types/detect-port": "^1.3.2",
110
110
  "@types/react-dom": "^18.0.3",
111
111
  "@types/react-router-config": "^5.0.6",
@@ -125,5 +125,5 @@
125
125
  "engines": {
126
126
  "node": ">=14"
127
127
  },
128
- "gitHead": "bd2b2328da8f23956a71e966ace97eb7cf951e7f"
128
+ "gitHead": "01073ce535af35aa33c1b221e2adb99ac993d589"
129
129
  }
@@ -1,9 +0,0 @@
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 { HostPortCLIOptions } from '@docusaurus/types';
8
- export declare function getCLIOptionHost(hostOption: HostPortCLIOptions['host']): string;
9
- export declare function getCLIOptionPort(portOption: HostPortCLIOptions['port'], host: string): Promise<number | null>;
@@ -1,20 +0,0 @@
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
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getCLIOptionPort = exports.getCLIOptionHost = void 0;
10
- const choosePort_1 = require("../server/choosePort");
11
- const utils_1 = require("@docusaurus/utils");
12
- function getCLIOptionHost(hostOption) {
13
- return hostOption ?? 'localhost';
14
- }
15
- exports.getCLIOptionHost = getCLIOptionHost;
16
- async function getCLIOptionPort(portOption, host) {
17
- const basePort = portOption ? parseInt(portOption, 10) : utils_1.DEFAULT_PORT;
18
- return (0, choosePort_1.choosePort)(host, basePort);
19
- }
20
- exports.getCLIOptionPort = getCLIOptionPort;
@@ -1,12 +0,0 @@
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>;