@docusaurus/core 0.0.0-5121 → 0.0.0-5124

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.
@@ -8,7 +8,6 @@
8
8
 
9
9
  // @ts-check
10
10
 
11
- import fs from 'fs-extra';
12
11
  import logger from '@docusaurus/logger';
13
12
  import cli from 'commander';
14
13
  import {DOCUSAURUS_VERSION} from '@docusaurus/utils';
@@ -27,8 +26,6 @@ import beforeCli from './beforeCli.mjs';
27
26
 
28
27
  await beforeCli();
29
28
 
30
- const resolveDir = (dir = '.') => fs.realpath(dir);
31
-
32
29
  cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
33
30
 
34
31
  cli
@@ -54,9 +51,9 @@ cli
54
51
  '--no-minify',
55
52
  'build website without minimizing JS bundles (default: false)',
56
53
  )
57
- .action(async (siteDir, options) => {
58
- await build(await resolveDir(siteDir), options);
59
- });
54
+ // @ts-expect-error: Promise<string> is not assignable to Promise<void>... but
55
+ // good enough here.
56
+ .action(build);
60
57
 
61
58
  cli
62
59
  .command('swizzle [themeName] [componentName] [siteDir]')
@@ -80,9 +77,7 @@ cli
80
77
  'copy TypeScript theme files when possible (default: false)',
81
78
  )
82
79
  .option('--danger', 'enable swizzle for unsafe component of themes')
83
- .action(async (themeName, componentName, siteDir, options) =>
84
- swizzle(await resolveDir(siteDir), themeName, componentName, options),
85
- );
80
+ .action(swizzle);
86
81
 
87
82
  cli
88
83
  .command('deploy [siteDir]')
@@ -103,9 +98,7 @@ cli
103
98
  '--skip-build',
104
99
  'skip building website before deploy it (default: false)',
105
100
  )
106
- .action(async (siteDir, options) =>
107
- deploy(await resolveDir(siteDir), options),
108
- );
101
+ .action(deploy);
109
102
 
110
103
  cli
111
104
  .command('start [siteDir]')
@@ -130,9 +123,7 @@ cli
130
123
  '--no-minify',
131
124
  'build website without minimizing JS bundles (default: false)',
132
125
  )
133
- .action(async (siteDir, options) =>
134
- start(await resolveDir(siteDir), options),
135
- );
126
+ .action(start);
136
127
 
137
128
  cli
138
129
  .command('serve [siteDir]')
@@ -152,14 +143,12 @@ cli
152
143
  '--no-open',
153
144
  'do not open page in the browser (default: false, or true in CI)',
154
145
  )
155
- .action(async (siteDir, options) =>
156
- serve(await resolveDir(siteDir), options),
157
- );
146
+ .action(serve);
158
147
 
159
148
  cli
160
149
  .command('clear [siteDir]')
161
150
  .description('Remove build artifacts.')
162
- .action(async (siteDir) => clear(await resolveDir(siteDir)));
151
+ .action(clear);
163
152
 
164
153
  cli
165
154
  .command('write-translations [siteDir]')
@@ -180,9 +169,7 @@ cli
180
169
  '--messagePrefix <messagePrefix>',
181
170
  'Allows to init new written messages with a given prefix. This might help you to highlight untranslated message by making them stand out in the UI (default: "")',
182
171
  )
183
- .action(async (siteDir, options) =>
184
- writeTranslations(await resolveDir(siteDir), options),
185
- );
172
+ .action(writeTranslations);
186
173
 
187
174
  cli
188
175
  .command('write-heading-ids [siteDir] [files...]')
@@ -192,9 +179,7 @@ cli
192
179
  "keep the headings' casing, otherwise make all lowercase (default: false)",
193
180
  )
194
181
  .option('--overwrite', 'overwrite existing heading IDs (default: false)')
195
- .action(async (siteDir, files, options) =>
196
- writeHeadingIds(await resolveDir(siteDir), files, options),
197
- );
182
+ .action(writeHeadingIds);
198
183
 
199
184
  cli.arguments('<command>').action((cmd) => {
200
185
  cli.outputHelp();
@@ -221,7 +206,7 @@ function isInternalCommand(command) {
221
206
  }
222
207
 
223
208
  if (!isInternalCommand(process.argv.slice(2)[0])) {
224
- await externalCommand(cli, await resolveDir('.'));
209
+ await externalCommand(cli);
225
210
  }
226
211
 
227
212
  if (!process.argv.slice(2).length) {
@@ -108,6 +108,9 @@ async function doRender(locals) {
108
108
  version: DOCUSAURUS_VERSION,
109
109
  });
110
110
  try {
111
+ if (process.env.SKIP_HTML_MINIFICATION === 'true') {
112
+ return renderedHtml;
113
+ }
111
114
  // Minify html with https://github.com/DanielRuf/html-minifier-terser
112
115
  return await minify(renderedHtml, {
113
116
  removeComments: false,
@@ -9,4 +9,4 @@ export declare type BuildCLIOptions = Pick<LoadContextOptions, 'config' | 'local
9
9
  bundleAnalyzer?: boolean;
10
10
  minify?: boolean;
11
11
  };
12
- export declare function build(siteDir: string, cliOptions: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
12
+ export declare function build(siteDirParam?: string, cliOptions?: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
@@ -23,12 +23,13 @@ const server_2 = tslib_1.__importDefault(require("../webpack/server"));
23
23
  const utils_2 = require("../webpack/utils");
24
24
  const CleanWebpackPlugin_1 = tslib_1.__importDefault(require("../webpack/plugins/CleanWebpackPlugin"));
25
25
  const i18n_1 = require("../server/i18n");
26
- async function build(siteDir, cliOptions,
26
+ async function build(siteDirParam = '.', cliOptions = {},
27
27
  // When running build, we force terminate the process to prevent async
28
28
  // operations from never returning. However, if run as part of docusaurus
29
29
  // deploy, we have to let deploy finish.
30
30
  // See https://github.com/facebook/docusaurus/pull/2496
31
31
  forceTerminate = true) {
32
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
32
33
  ['SIGINT', 'SIGTERM'].forEach((sig) => {
33
34
  process.on(sig, () => process.exit());
34
35
  });
@@ -4,4 +4,4 @@
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
- export declare function clear(siteDir: string): Promise<void>;
7
+ export declare function clear(siteDirParam?: string): Promise<void>;
@@ -25,7 +25,8 @@ async function removePath(entry) {
25
25
  logger_1.default.error(err);
26
26
  }
27
27
  }
28
- async function clear(siteDir) {
28
+ async function clear(siteDirParam = '.') {
29
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
29
30
  const generatedFolder = {
30
31
  path: path_1.default.join(siteDir, utils_1.GENERATED_FILES_DIR_NAME),
31
32
  description: 'generated folder',
@@ -8,4 +8,4 @@ import { type LoadContextOptions } from '../server';
8
8
  export declare type DeployCLIOptions = Pick<LoadContextOptions, 'config' | 'locale' | 'outDir'> & {
9
9
  skipBuild?: boolean;
10
10
  };
11
- export declare function deploy(siteDir: string, cliOptions: Partial<DeployCLIOptions>): Promise<void>;
11
+ export declare function deploy(siteDirParam?: string, cliOptions?: Partial<DeployCLIOptions>): Promise<void>;
@@ -34,7 +34,8 @@ function shellExecLog(cmd) {
34
34
  throw err;
35
35
  }
36
36
  }
37
- async function deploy(siteDir, cliOptions) {
37
+ async function deploy(siteDirParam = '.', cliOptions = {}) {
38
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
38
39
  const { outDir, siteConfig, siteConfigPath } = await (0, server_1.loadContext)({
39
40
  siteDir,
40
41
  config: cliOptions.config,
@@ -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 declare function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
8
+ export declare function externalCommand(cli: CommanderStatic): Promise<void>;
@@ -7,9 +7,12 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.externalCommand = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
10
12
  const server_1 = require("../server");
11
13
  const init_1 = require("../server/plugins/init");
12
- async function externalCommand(cli, siteDir) {
14
+ async function externalCommand(cli) {
15
+ const siteDir = await fs_extra_1.default.realpath('.');
13
16
  const context = await (0, server_1.loadContext)({ siteDir });
14
17
  const plugins = await (0, init_1.initPlugins)(context);
15
18
  // Plugin Lifecycle - extendCli.
@@ -11,4 +11,4 @@ export declare type ServeCLIOptions = HostPortOptions & Pick<LoadContextOptions,
11
11
  build?: boolean;
12
12
  open?: boolean;
13
13
  };
14
- export declare function serve(siteDir: string, cliOptions: Partial<ServeCLIOptions>): Promise<void>;
14
+ export declare function serve(siteDirParam?: string, cliOptions?: Partial<ServeCLIOptions>): Promise<void>;
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.serve = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const http_1 = tslib_1.__importDefault(require("http"));
12
13
  const path_1 = tslib_1.__importDefault(require("path"));
13
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -17,7 +18,8 @@ const openBrowser_1 = tslib_1.__importDefault(require("react-dev-utils/openBrows
17
18
  const config_1 = require("../server/config");
18
19
  const build_1 = require("./build");
19
20
  const getHostPort_1 = require("../server/getHostPort");
20
- async function serve(siteDir, cliOptions) {
21
+ async function serve(siteDirParam = '.', cliOptions = {}) {
22
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
21
23
  const buildDir = cliOptions.dir ?? utils_1.DEFAULT_BUILD_DIR_NAME;
22
24
  let dir = path_1.default.resolve(siteDir, buildDir);
23
25
  if (cliOptions.build) {
@@ -12,4 +12,4 @@ export declare type StartCLIOptions = HostPortOptions & Pick<LoadContextOptions,
12
12
  poll?: boolean | number;
13
13
  minify?: boolean;
14
14
  };
15
- export declare function start(siteDir: string, cliOptions: Partial<StartCLIOptions>): Promise<void>;
15
+ export declare function start(siteDirParam?: string, cliOptions?: Partial<StartCLIOptions>): Promise<void>;
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.start = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const path_1 = tslib_1.__importDefault(require("path"));
12
13
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -24,7 +25,8 @@ const server_1 = require("../server");
24
25
  const client_1 = tslib_1.__importDefault(require("../webpack/client"));
25
26
  const utils_2 = require("../webpack/utils");
26
27
  const getHostPort_1 = require("../server/getHostPort");
27
- async function start(siteDir, cliOptions) {
28
+ async function start(siteDirParam = '.', cliOptions = {}) {
29
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
28
30
  process.env.NODE_ENV = 'development';
29
31
  process.env.BABEL_ENV = 'development';
30
32
  logger_1.default.info('Starting the development server...');
@@ -69,11 +69,12 @@ async function wrap({ siteDir, themePath, componentName: themeComponentName, typ
69
69
  await fs_extra_1.default.ensureDir(path_1.default.resolve(siteDir, utils_1.THEME_PATH));
70
70
  const toPath = path_1.default.resolve(siteDir, utils_1.THEME_PATH, wrapperFileName);
71
71
  const content = typescript
72
- ? `import React, {ComponentProps} from 'react';
72
+ ? `import React from 'react';
73
73
  import ${componentName} from '@theme-${importType}/${themeComponentName}';
74
74
  import type ${componentName}Type from '@theme/${themeComponentName}';
75
+ import type {WrapperProps} from '@docusaurus/types';
75
76
 
76
- type Props = ComponentProps<typeof ${componentName}Type>;
77
+ type Props = WrapperProps<typeof ${componentName}Type>;
77
78
 
78
79
  export default function ${wrapperComponentName}(props: Props): JSX.Element {
79
80
  return (
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { SwizzleCLIOptions } from './common';
8
- export declare function swizzle(siteDir: string, themeNameParam: string | undefined, componentNameParam: string | undefined, optionsParam: Partial<SwizzleCLIOptions>): Promise<void>;
8
+ export declare function swizzle(themeNameParam?: string | undefined, componentNameParam?: string | undefined, siteDirParam?: string, optionsParam?: Partial<SwizzleCLIOptions>): Promise<void>;
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.swizzle = void 0;
10
10
  const tslib_1 = require("tslib");
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 themes_1 = require("./themes");
13
14
  const components_1 = require("./components");
@@ -57,7 +58,8 @@ If you want to swizzle it, use the code=${'--danger'} flag, or confirm that you
57
58
  }
58
59
  return undefined;
59
60
  }
60
- async function swizzle(siteDir, themeNameParam, componentNameParam, optionsParam) {
61
+ async function swizzle(themeNameParam = undefined, componentNameParam = undefined, siteDirParam = '.', optionsParam = {}) {
62
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
61
63
  const options = (0, common_1.normalizeOptions)(optionsParam);
62
64
  const { list, danger, typescript } = options;
63
65
  const { plugins } = await (0, context_1.initSwizzleContext)(siteDir);
@@ -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 declare function writeHeadingIds(siteDir: string, files: string[] | undefined, options: WriteHeadingIDOptions): Promise<void>;
8
+ export declare function writeHeadingIds(siteDirParam?: string, files?: string[], options?: WriteHeadingIDOptions): Promise<void>;
@@ -34,7 +34,8 @@ async function getPathsToWatch(siteDir) {
34
34
  const plugins = await (0, init_1.initPlugins)(context);
35
35
  return plugins.flatMap((plugin) => plugin.getPathsToWatch?.() ?? []);
36
36
  }
37
- async function writeHeadingIds(siteDir, files, options) {
37
+ async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
38
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
38
39
  const markdownFiles = await (0, utils_2.safeGlobby)(files ?? (await getPathsToWatch(siteDir)), {
39
40
  expandDirectories: ['**/*.{md,mdx}'],
40
41
  });
@@ -7,4 +7,4 @@
7
7
  import { type LoadContextOptions } from '../server';
8
8
  import { type WriteTranslationsOptions } from '../server/translations/translations';
9
9
  export declare type WriteTranslationsCLIOptions = Pick<LoadContextOptions, 'config' | 'locale'> & WriteTranslationsOptions;
10
- export declare function writeTranslations(siteDir: string, options: Partial<WriteTranslationsCLIOptions>): Promise<void>;
10
+ export declare function writeTranslations(siteDirParam?: string, options?: Partial<WriteTranslationsCLIOptions>): Promise<void>;
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.writeTranslations = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const path_1 = tslib_1.__importDefault(require("path"));
12
13
  const server_1 = require("../server");
13
14
  const init_1 = require("../server/plugins/init");
@@ -46,7 +47,8 @@ async function writePluginTranslationFiles({ localizationDir, plugin, options, }
46
47
  }));
47
48
  }
48
49
  }
49
- async function writeTranslations(siteDir, options) {
50
+ async function writeTranslations(siteDirParam = '.', options = {}) {
51
+ const siteDir = await fs_extra_1.default.realpath(siteDirParam);
50
52
  const context = await (0, server_1.loadContext)({
51
53
  siteDir,
52
54
  config: options.config,
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-5121",
4
+ "version": "0.0.0-5124",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,13 +43,13 @@
43
43
  "@babel/runtime": "^7.18.3",
44
44
  "@babel/runtime-corejs3": "^7.18.3",
45
45
  "@babel/traverse": "^7.18.2",
46
- "@docusaurus/cssnano-preset": "0.0.0-5121",
47
- "@docusaurus/logger": "0.0.0-5121",
48
- "@docusaurus/mdx-loader": "0.0.0-5121",
46
+ "@docusaurus/cssnano-preset": "0.0.0-5124",
47
+ "@docusaurus/logger": "0.0.0-5124",
48
+ "@docusaurus/mdx-loader": "0.0.0-5124",
49
49
  "@docusaurus/react-loadable": "5.5.2",
50
- "@docusaurus/utils": "0.0.0-5121",
51
- "@docusaurus/utils-common": "0.0.0-5121",
52
- "@docusaurus/utils-validation": "0.0.0-5121",
50
+ "@docusaurus/utils": "0.0.0-5124",
51
+ "@docusaurus/utils-common": "0.0.0-5124",
52
+ "@docusaurus/utils-validation": "0.0.0-5124",
53
53
  "@slorber/static-site-generator-webpack-plugin": "^4.0.7",
54
54
  "@svgr/webpack": "^6.2.1",
55
55
  "autoprefixer": "^10.4.7",
@@ -106,8 +106,8 @@
106
106
  "webpackbar": "^5.0.2"
107
107
  },
108
108
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "0.0.0-5121",
110
- "@docusaurus/types": "0.0.0-5121",
109
+ "@docusaurus/module-type-aliases": "0.0.0-5124",
110
+ "@docusaurus/types": "0.0.0-5124",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/react-dom": "^18.0.5",
113
113
  "@types/react-router-config": "^5.0.6",
@@ -127,5 +127,5 @@
127
127
  "engines": {
128
128
  "node": ">=16.14"
129
129
  },
130
- "gitHead": "70d9c6badffc9f018d8ead96c973ffbc4eefd069"
130
+ "gitHead": "dba5e8d5a7bc07b946888664f9cc3f07564093e1"
131
131
  }