@docusaurus/core 0.0.0-4632 → 0.0.0-4635

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.
@@ -0,0 +1,115 @@
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
+ const tslib_1 = require("tslib");
10
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const themes_1 = require("./themes");
12
+ const components_1 = require("./components");
13
+ const tables_1 = require("./tables");
14
+ const common_1 = require("./common");
15
+ const actions_1 = require("./actions");
16
+ const config_1 = require("./config");
17
+ const prompts_1 = require("./prompts");
18
+ const context_1 = require("./context");
19
+ async function listAllThemeComponents({ themeNames, plugins, typescript, }) {
20
+ const themeComponentsTables = (await Promise.all(themeNames.map(async (themeName) => {
21
+ const themePath = (0, themes_1.getThemePath)({ themeName, plugins, typescript });
22
+ const swizzleConfig = (0, config_1.getThemeSwizzleConfig)(themeName, plugins);
23
+ const themeComponents = await (0, components_1.getThemeComponents)({
24
+ themeName,
25
+ themePath,
26
+ swizzleConfig,
27
+ });
28
+ return (0, tables_1.themeComponentsTable)(themeComponents);
29
+ }))).join('\n\n');
30
+ logger_1.default.info(`All theme components available to swizzle:
31
+
32
+ ${themeComponentsTables}
33
+
34
+ ${(0, tables_1.helpTables)()}
35
+ `);
36
+ return process.exit(0);
37
+ }
38
+ async function ensureActionSafety({ componentName, componentConfig, action, danger, }) {
39
+ const actionStatus = componentConfig.actions[action];
40
+ if (actionStatus === 'forbidden') {
41
+ logger_1.default.error `
42
+ Swizzle action name=${action} is forbidden for component name=${componentName}
43
+ `;
44
+ return process.exit(1);
45
+ }
46
+ if (actionStatus === 'unsafe' && !danger) {
47
+ logger_1.default.warn `
48
+ Swizzle action name=${action} is unsafe to perform on name=${componentName}.
49
+ It is more likely to be affected by breaking changes in the future
50
+ If you want to swizzle it, use the code=${'--danger'} flag, or confirm that you understand the risks.
51
+ `;
52
+ const swizzleDangerousComponent = await (0, prompts_1.askSwizzleDangerousComponent)();
53
+ if (!swizzleDangerousComponent) {
54
+ return process.exit(1);
55
+ }
56
+ }
57
+ return undefined;
58
+ }
59
+ async function swizzle(siteDir, themeNameParam, componentNameParam, optionsParam) {
60
+ const options = (0, common_1.normalizeOptions)(optionsParam);
61
+ const { list, danger, typescript } = options;
62
+ const { plugins } = await (0, context_1.initSwizzleContext)(siteDir);
63
+ const themeNames = (0, themes_1.getThemeNames)(plugins);
64
+ if (list && !themeNameParam) {
65
+ await listAllThemeComponents({ themeNames, plugins, typescript });
66
+ }
67
+ const themeName = await (0, themes_1.getThemeName)({ themeNameParam, themeNames, list });
68
+ const themePath = (0, themes_1.getThemePath)({ themeName, plugins, typescript });
69
+ const swizzleConfig = (0, config_1.getThemeSwizzleConfig)(themeName, plugins);
70
+ const themeComponents = await (0, components_1.getThemeComponents)({
71
+ themeName,
72
+ themePath,
73
+ swizzleConfig,
74
+ });
75
+ const componentName = await (0, components_1.getComponentName)({
76
+ componentNameParam,
77
+ themeComponents,
78
+ list,
79
+ });
80
+ const componentConfig = themeComponents.getConfig(componentName);
81
+ const action = await (0, actions_1.getAction)(componentConfig, options);
82
+ await ensureActionSafety({ componentName, componentConfig, action, danger });
83
+ async function executeAction() {
84
+ switch (action) {
85
+ case 'wrap': {
86
+ const result = await (0, actions_1.wrap)({
87
+ siteDir,
88
+ themePath,
89
+ componentName,
90
+ typescript,
91
+ });
92
+ logger_1.default.success `
93
+ Created wrapper of name=${componentName} from name=${themeName} in path=${result.createdFiles}.
94
+ `;
95
+ return result;
96
+ }
97
+ case 'eject': {
98
+ const result = await (0, actions_1.eject)({
99
+ siteDir,
100
+ themePath,
101
+ componentName,
102
+ });
103
+ logger_1.default.success `
104
+ Ejected name=${componentName} from name=${themeName} to path=${result.createdFiles}.
105
+ `;
106
+ return result;
107
+ }
108
+ default:
109
+ throw new Error(`Unexpected action ${action}`);
110
+ }
111
+ }
112
+ await executeAction();
113
+ return process.exit(0);
114
+ }
115
+ exports.default = swizzle;
@@ -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 { ThemeComponents } from './components';
8
+ import type { SwizzleAction, SwizzleComponentConfig } from '@docusaurus/types';
9
+ export declare function askThemeName(themeNames: string[]): Promise<string>;
10
+ export declare function askComponentName(themeComponents: ThemeComponents): Promise<string>;
11
+ export declare function askSwizzleDangerousComponent(): Promise<boolean>;
12
+ export declare function askSwizzleAction(componentConfig: SwizzleComponentConfig): Promise<SwizzleAction>;
@@ -0,0 +1,110 @@
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.askSwizzleAction = exports.askSwizzleDangerousComponent = exports.askComponentName = exports.askThemeName = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
+ const prompts_1 = (0, tslib_1.__importDefault)(require("prompts"));
13
+ const common_1 = require("./common");
14
+ const ExitTitle = logger_1.default.yellow('[Exit]');
15
+ async function askThemeName(themeNames) {
16
+ const { themeName } = await (0, prompts_1.default)({
17
+ type: 'select',
18
+ name: 'themeName',
19
+ message: 'Select a theme to swizzle:',
20
+ choices: themeNames
21
+ .map((theme) => ({ title: theme, value: theme }))
22
+ .concat({ title: ExitTitle, value: '[Exit]' }),
23
+ });
24
+ if (!themeName || themeName === '[Exit]') {
25
+ process.exit(0);
26
+ }
27
+ return themeName;
28
+ }
29
+ exports.askThemeName = askThemeName;
30
+ async function askComponentName(themeComponents) {
31
+ function formatComponentName(componentName) {
32
+ const anySafe = themeComponents.hasAnySafeAction(componentName);
33
+ const allSafe = themeComponents.hasAllSafeAction(componentName);
34
+ const safestStatus = anySafe ? 'safe' : 'unsafe'; // Not 100% accurate but good enough for now.
35
+ const partiallySafe = anySafe && !allSafe;
36
+ return `${componentName}${(0, common_1.actionStatusSuffix)(safestStatus, {
37
+ partiallySafe,
38
+ })}`;
39
+ }
40
+ const { componentName } = await (0, prompts_1.default)({
41
+ type: 'autocomplete',
42
+ name: 'componentName',
43
+ message: `
44
+ Select or type the component to swizzle.
45
+ ${common_1.PartiallySafeHint} = not safe for all swizzle actions
46
+ `,
47
+ // This doesn't work well in small-height terminals (like IDE)
48
+ // limit: 30,
49
+ // This does not work well and messes up with terminal scroll position
50
+ // limit: Number.POSITIVE_INFINITY,
51
+ choices: themeComponents.all
52
+ .map((compName) => ({
53
+ title: formatComponentName(compName),
54
+ value: compName,
55
+ }))
56
+ .concat({ title: ExitTitle, value: '[Exit]' }),
57
+ async suggest(input, choices) {
58
+ return choices.filter((choice) => choice.title.toLowerCase().includes(input.toLowerCase()));
59
+ },
60
+ });
61
+ logger_1.default.newLine();
62
+ if (!componentName || componentName === '[Exit]') {
63
+ return process.exit(0);
64
+ }
65
+ return componentName;
66
+ }
67
+ exports.askComponentName = askComponentName;
68
+ async function askSwizzleDangerousComponent() {
69
+ const { switchToDanger } = await (0, prompts_1.default)({
70
+ type: 'select',
71
+ name: 'switchToDanger',
72
+ message: `Do you really want to swizzle this unsafe internal component?`,
73
+ choices: [
74
+ { title: logger_1.default.green('NO: cancel and stay safe'), value: false },
75
+ {
76
+ title: logger_1.default.red('YES: I know what I am doing!'),
77
+ value: true,
78
+ },
79
+ { title: ExitTitle, value: '[Exit]' },
80
+ ],
81
+ });
82
+ if (typeof switchToDanger === 'undefined' || switchToDanger === '[Exit]') {
83
+ return process.exit(0);
84
+ }
85
+ return !!switchToDanger;
86
+ }
87
+ exports.askSwizzleDangerousComponent = askSwizzleDangerousComponent;
88
+ async function askSwizzleAction(componentConfig) {
89
+ const { action } = await (0, prompts_1.default)({
90
+ type: 'select',
91
+ name: 'action',
92
+ message: `Which swizzle action do you want to do?`,
93
+ choices: [
94
+ {
95
+ title: `${logger_1.default.bold('Wrap')}${(0, common_1.actionStatusSuffix)(componentConfig.actions.wrap)}`,
96
+ value: 'wrap',
97
+ },
98
+ {
99
+ title: `${logger_1.default.bold('Eject')}${(0, common_1.actionStatusSuffix)(componentConfig.actions.eject)}`,
100
+ value: 'eject',
101
+ },
102
+ { title: ExitTitle, value: '[Exit]' },
103
+ ],
104
+ });
105
+ if (typeof action === 'undefined' || action === '[Exit]') {
106
+ return process.exit(0);
107
+ }
108
+ return action;
109
+ }
110
+ exports.askSwizzleAction = askSwizzleAction;
@@ -0,0 +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
+ */
7
+ import type { ThemeComponents } from './components';
8
+ export declare function helpTables(): string;
9
+ export declare function themeComponentsTable(themeComponents: ThemeComponents): string;
@@ -0,0 +1,116 @@
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.themeComponentsTable = exports.helpTables = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
+ const cli_table3_1 = (0, tslib_1.__importDefault)(require("cli-table3"));
13
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
14
+ const actions_1 = require("./actions");
15
+ const common_1 = require("./common");
16
+ function tableStatusLabel(status) {
17
+ return (0, common_1.actionStatusColor)(status, (0, common_1.actionStatusLabel)(status));
18
+ }
19
+ function getStatusLabel(status) {
20
+ return (0, common_1.actionStatusColor)(status, (0, common_1.actionStatusLabel)(status));
21
+ }
22
+ function statusTable() {
23
+ const table = new cli_table3_1.default({
24
+ head: ['Status', 'CLI option', 'Description'],
25
+ });
26
+ table.push({
27
+ [tableStatusLabel('safe')]: [
28
+ '',
29
+ `
30
+ This component is safe to swizzle and was designed for this purpose.
31
+ The swizzled component is retro-compatible with minor version upgrades.
32
+ `,
33
+ ],
34
+ });
35
+ table.push({
36
+ [tableStatusLabel('unsafe')]: [
37
+ logger_1.default.code('--danger'),
38
+ `
39
+ This component is unsafe to swizzle, but you can still do it!
40
+ Warning: we may release breaking changes within minor version upgrades.
41
+ You will have to upgrade your component manually and maintain it over time.
42
+
43
+ ${logger_1.default.green('Tip')}: your customization can't be done in a ${tableStatusLabel('safe')} way?
44
+ Report it here: https://github.com/facebook/docusaurus/discussions/5468
45
+ `,
46
+ ],
47
+ });
48
+ table.push({
49
+ [tableStatusLabel('forbidden')]: [
50
+ '',
51
+ `
52
+ This component should not meant to be swizzled.
53
+ `,
54
+ ],
55
+ });
56
+ return table.toString();
57
+ }
58
+ function actionsTable() {
59
+ const table = new cli_table3_1.default({
60
+ head: ['Actions', 'CLI option', 'Description'],
61
+ });
62
+ table.push({
63
+ [logger_1.default.bold('Wrap')]: [
64
+ logger_1.default.code('--wrap'),
65
+ `
66
+ Creates a wrapper around the original theme component.
67
+ Allows rendering other components before/after the original theme component.
68
+
69
+ ${logger_1.default.green('Tip')}: prefer ${logger_1.default.code('--wrap')} whenever possible to reduces the amount of code to maintain.
70
+ `,
71
+ ],
72
+ });
73
+ table.push({
74
+ [logger_1.default.bold('Eject')]: [
75
+ logger_1.default.code('--eject'),
76
+ `
77
+ Ejects the full source code of the original theme component.
78
+ Allows overriding the original component entirely with your own UI and logic.
79
+
80
+ ${logger_1.default.green('Tip')}: ${logger_1.default.code('--eject')} can be useful to completely redesign a component.
81
+ `,
82
+ ],
83
+ });
84
+ return table.toString();
85
+ }
86
+ function helpTables() {
87
+ return `${logger_1.default.bold('Swizzle actions')}:
88
+ ${actionsTable()}
89
+
90
+ ${logger_1.default.bold('Swizzle safety statuses')}:
91
+ ${statusTable()}
92
+
93
+ ${logger_1.default.bold('Swizzle guide')}: https://docusaurus.io/docs/swizzling`;
94
+ }
95
+ exports.helpTables = helpTables;
96
+ function themeComponentsTable(themeComponents) {
97
+ const table = new cli_table3_1.default({
98
+ head: [
99
+ 'Component name',
100
+ ...actions_1.SwizzleActions.map((action) => lodash_1.default.capitalize(action)),
101
+ 'Description',
102
+ ],
103
+ });
104
+ themeComponents.all.forEach((component) => {
105
+ table.push({
106
+ [component]: [
107
+ ...actions_1.SwizzleActions.map((action) => getStatusLabel(themeComponents.getActionStatus(component, action))),
108
+ themeComponents.getDescription(component),
109
+ ],
110
+ });
111
+ });
112
+ return `${logger_1.default.bold(`Components available for swizzle in ${logger_1.default.name(themeComponents.themeName)}`)}:
113
+ ${table.toString()}
114
+ `;
115
+ }
116
+ exports.themeComponentsTable = themeComponentsTable;
@@ -0,0 +1,20 @@
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 SwizzlePlugin } from './common';
8
+ export declare function pluginToThemeName(plugin: SwizzlePlugin): string | undefined;
9
+ export declare function getPluginByThemeName(plugins: SwizzlePlugin[], themeName: string): SwizzlePlugin;
10
+ export declare function getThemeNames(plugins: SwizzlePlugin[]): string[];
11
+ export declare function getThemeName({ themeNameParam, themeNames, list, }: {
12
+ themeNameParam: string | undefined;
13
+ themeNames: string[];
14
+ list: boolean | undefined;
15
+ }): Promise<string>;
16
+ export declare function getThemePath({ plugins, themeName, typescript, }: {
17
+ plugins: SwizzlePlugin[];
18
+ themeName: string;
19
+ typescript: boolean | undefined;
20
+ }): string;
@@ -0,0 +1,105 @@
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.getThemePath = exports.getThemeName = exports.getThemeNames = exports.getPluginByThemeName = exports.pluginToThemeName = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
+ const leven_1 = (0, tslib_1.__importDefault)(require("leven"));
13
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
14
+ const prompts_1 = require("./prompts");
15
+ const common_1 = require("./common");
16
+ function pluginToThemeName(plugin) {
17
+ var _a;
18
+ if (plugin.instance.getThemePath) {
19
+ return ((_a = plugin.instance.version.name) !== null && _a !== void 0 ? _a : plugin.instance.name);
20
+ }
21
+ return undefined;
22
+ }
23
+ exports.pluginToThemeName = pluginToThemeName;
24
+ function getPluginByThemeName(plugins, themeName) {
25
+ const plugin = plugins.find((p) => pluginToThemeName(p) === themeName);
26
+ if (!plugin) {
27
+ throw new Error(`Theme ${themeName} not found`);
28
+ }
29
+ return plugin;
30
+ }
31
+ exports.getPluginByThemeName = getPluginByThemeName;
32
+ function getThemeNames(plugins) {
33
+ const themeNames = lodash_1.default.uniq(
34
+ // The fact that getThemePath is attached to the plugin instance makes
35
+ // this code impossible to optimize. If this is a static method, we don't
36
+ // need to initialize all plugins just to filter which are themes
37
+ // Benchmark: loadContext-58ms; initPlugins-323ms
38
+ plugins.map((plugin) => pluginToThemeName(plugin)).filter(Boolean));
39
+ // Opinionated ordering: user is most likely to swizzle:
40
+ // - the classic theme
41
+ // - official themes
42
+ // - official plugins
43
+ return lodash_1.default.orderBy(themeNames, [
44
+ (t) => t === '@docusaurus/theme-classic',
45
+ (t) => t.includes('@docusaurus/theme'),
46
+ (t) => t.includes('@docusaurus'),
47
+ ], ['desc', 'desc', 'desc']);
48
+ }
49
+ exports.getThemeNames = getThemeNames;
50
+ // Returns a valid value if recovering is possible
51
+ function handleInvalidThemeName({ themeNameParam, themeNames, }) {
52
+ // Trying to recover invalid value
53
+ // We look for potential matches that only differ in casing.
54
+ const differentCaseMatch = (0, common_1.findStringIgnoringCase)(themeNameParam, themeNames);
55
+ if (differentCaseMatch) {
56
+ logger_1.default.warn `Theme name=${themeNameParam} doesn't exist.`;
57
+ logger_1.default.info `name=${differentCaseMatch} will be used instead of name=${themeNameParam}.`;
58
+ return differentCaseMatch;
59
+ }
60
+ // TODO recover from short theme-names here: "classic" => "@docusaurus/theme-classic"
61
+ // No recovery value is possible: print error
62
+ const suggestion = themeNames.find((name) => (0, leven_1.default)(name, themeNameParam) < 4);
63
+ logger_1.default.error `Theme name=${themeNameParam} not found. ${suggestion
64
+ ? logger_1.default.interpolate `Did you mean name=${suggestion}?`
65
+ : logger_1.default.interpolate `Themes available for swizzle: ${themeNames}`}`;
66
+ return process.exit(1);
67
+ }
68
+ async function validateThemeName({ themeNameParam, themeNames, }) {
69
+ const isValidName = themeNames.includes(themeNameParam);
70
+ if (!isValidName) {
71
+ return handleInvalidThemeName({
72
+ themeNameParam,
73
+ themeNames,
74
+ });
75
+ }
76
+ return themeNameParam;
77
+ }
78
+ async function getThemeName({ themeNameParam, themeNames, list, }) {
79
+ if (list && !themeNameParam) {
80
+ logger_1.default.info `Themes available for swizzle: name=${themeNames}`;
81
+ return process.exit(0);
82
+ }
83
+ return themeNameParam
84
+ ? validateThemeName({ themeNameParam, themeNames })
85
+ : (0, prompts_1.askThemeName)(themeNames);
86
+ }
87
+ exports.getThemeName = getThemeName;
88
+ function getThemePath({ plugins, themeName, typescript, }) {
89
+ var _a, _b, _c, _d;
90
+ const pluginInstance = getPluginByThemeName(plugins, themeName);
91
+ const themePath = typescript
92
+ ? (_b = (_a = pluginInstance.instance).getTypeScriptThemePath) === null || _b === void 0 ? void 0 : _b.call(_a)
93
+ : (_d = (_c = pluginInstance.instance).getThemePath) === null || _d === void 0 ? void 0 : _d.call(_c);
94
+ if (!themePath) {
95
+ logger_1.default.warn(typescript
96
+ ? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
97
+ : // This is... technically possible to happen, e.g. returning undefined
98
+ // from getThemePath. Plugins may intentionally or unintentionally
99
+ // disguise as themes?
100
+ logger_1.default.interpolate `name=${themeName} does not provide any theme code.`);
101
+ return process.exit(1);
102
+ }
103
+ return themePath;
104
+ }
105
+ exports.getThemePath = getThemePath;
@@ -4,7 +4,17 @@
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, PluginConfig, InitializedPlugin } from '@docusaurus/types';
7
+ /// <reference types="node" />
8
+ import type { ImportedPluginModule, LoadContext, PluginModule, PluginConfig, PluginOptions, InitializedPlugin } from '@docusaurus/types';
9
+ export declare type NormalizedPluginConfig = {
10
+ plugin: PluginModule;
11
+ options: PluginOptions;
12
+ pluginModule?: {
13
+ path: string;
14
+ module: ImportedPluginModule;
15
+ };
16
+ };
17
+ export declare function normalizePluginConfigs(pluginConfigs: PluginConfig[], pluginRequire: NodeRequire): Promise<NormalizedPluginConfig[]>;
8
18
  export default function initPlugins({ pluginConfigs, context, }: {
9
19
  pluginConfigs: PluginConfig[];
10
20
  context: LoadContext;
@@ -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.normalizePluginConfigs = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const module_1 = require("module");
11
12
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
@@ -65,6 +66,10 @@ async function normalizePluginConfig(pluginConfig, pluginRequire) {
65
66
  }
66
67
  throw new Error(`Unexpected: can't load plugin for following plugin config.\n${JSON.stringify(pluginConfig)}`);
67
68
  }
69
+ async function normalizePluginConfigs(pluginConfigs, pluginRequire) {
70
+ return Promise.all(pluginConfigs.map((pluginConfig) => normalizePluginConfig(pluginConfig, pluginRequire)));
71
+ }
72
+ exports.normalizePluginConfigs = normalizePluginConfigs;
68
73
  function getOptionValidationFunction(normalizedPluginConfig) {
69
74
  var _a, _b, _c, _d;
70
75
  if (normalizedPluginConfig.pluginModule) {
@@ -85,6 +90,7 @@ async function initPlugins({ pluginConfigs, context, }) {
85
90
  // We need to resolve plugins from the perspective of the siteDir, since the
86
91
  // siteDir's package.json declares the dependency on these plugins.
87
92
  const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
93
+ const pluginConfigsNormalized = await normalizePluginConfigs(pluginConfigs, pluginRequire);
88
94
  async function doGetPluginVersion(normalizedPluginConfig) {
89
95
  var _a, _b;
90
96
  // get plugin version
@@ -120,8 +126,7 @@ async function initPlugins({ pluginConfigs, context, }) {
120
126
  id: (_a = normalizedPluginConfig.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID,
121
127
  };
122
128
  }
123
- async function initializePlugin(pluginConfig) {
124
- const normalizedPluginConfig = await normalizePluginConfig(pluginConfig, pluginRequire);
129
+ async function initializePlugin(normalizedPluginConfig) {
125
130
  const pluginVersion = await doGetPluginVersion(normalizedPluginConfig);
126
131
  const pluginOptions = doValidatePluginOptions(normalizedPluginConfig);
127
132
  // Side-effect: merge the normalized theme config in the original one
@@ -136,7 +141,7 @@ async function initPlugins({ pluginConfigs, context, }) {
136
141
  version: pluginVersion,
137
142
  };
138
143
  }
139
- const plugins = (await Promise.all(pluginConfigs.map((pluginConfig) => {
144
+ const plugins = (await Promise.all(pluginConfigsNormalized.map((pluginConfig) => {
140
145
  if (!pluginConfig) {
141
146
  return null;
142
147
  }
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-4632",
4
+ "version": "0.0.0-4635",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.2",
42
42
  "@babel/runtime-corejs3": "^7.17.2",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4632",
45
- "@docusaurus/logger": "0.0.0-4632",
46
- "@docusaurus/mdx-loader": "0.0.0-4632",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4635",
45
+ "@docusaurus/logger": "0.0.0-4635",
46
+ "@docusaurus/mdx-loader": "0.0.0-4635",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4632",
49
- "@docusaurus/utils-common": "0.0.0-4632",
50
- "@docusaurus/utils-validation": "0.0.0-4632",
48
+ "@docusaurus/utils": "0.0.0-4635",
49
+ "@docusaurus/utils-common": "0.0.0-4635",
50
+ "@docusaurus/utils-validation": "0.0.0-4635",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.1",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.2",
@@ -56,6 +56,7 @@
56
56
  "boxen": "^6.2.1",
57
57
  "chokidar": "^3.5.3",
58
58
  "clean-css": "^5.2.4",
59
+ "cli-table3": "^0.6.1",
59
60
  "combine-promises": "^1.1.0",
60
61
  "commander": "^5.1.0",
61
62
  "copy-webpack-plugin": "^10.2.4",
@@ -105,8 +106,8 @@
105
106
  "webpackbar": "^5.0.2"
106
107
  },
107
108
  "devDependencies": {
108
- "@docusaurus/module-type-aliases": "0.0.0-4632",
109
- "@docusaurus/types": "0.0.0-4632",
109
+ "@docusaurus/module-type-aliases": "0.0.0-4635",
110
+ "@docusaurus/types": "0.0.0-4635",
110
111
  "@types/detect-port": "^1.3.2",
111
112
  "@types/nprogress": "^0.2.0",
112
113
  "@types/react-dom": "^17.0.11",
@@ -117,7 +118,8 @@
117
118
  "@types/wait-on": "^5.3.1",
118
119
  "@types/webpack-bundle-analyzer": "^4.4.1",
119
120
  "react-test-renderer": "^17.0.2",
120
- "tmp-promise": "^3.0.3"
121
+ "tmp-promise": "^3.0.3",
122
+ "tree-node-cli": "^1.5.2"
121
123
  },
122
124
  "peerDependencies": {
123
125
  "react": "^16.8.4 || ^17.0.0",
@@ -126,5 +128,5 @@
126
128
  "engines": {
127
129
  "node": ">=14"
128
130
  },
129
- "gitHead": "71b49c9f003f9388f0e329846dce3d8ea82d5bc0"
131
+ "gitHead": "267eecbcba13dd00dd8b9a23bde16cfb2171ae7f"
130
132
  }
@@ -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 { PluginConfig } from '@docusaurus/types';
8
- export declare function getPluginNames(plugins: PluginConfig[]): string[];
9
- export default function swizzle(siteDir: string, themeName?: string, componentName?: string, typescript?: boolean, danger?: boolean): Promise<void>;