@docusaurus/plugin-content-docs 0.0.0-4524 → 0.0.0-4531

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/cli.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 { PathOptions, SidebarOptions } from '@docusaurus/plugin-content-docs';
8
- export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): void;
8
+ export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): Promise<void>;
package/lib/cli.js CHANGED
@@ -14,11 +14,11 @@ const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
14
  const sidebars_1 = require("./sidebars");
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
17
- function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
17
+ async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
18
18
  // Load current sidebar and create a new versioned sidebars file (if needed).
19
19
  // Note: we don't need the sidebars file to be normalized: it's ok to let
20
20
  // plugin option changes to impact older, versioned sidebars
21
- const sidebars = (0, sidebars_1.loadSidebarsFile)(sidebarPath);
21
+ const sidebars = await (0, sidebars_1.loadSidebarsFile)(sidebarPath);
22
22
  // Do not create a useless versioned sidebars file if sidebars file is empty
23
23
  // or sidebars are disabled/false)
24
24
  const shouldCreateVersionedSidebarFile = Object.keys(sidebars).length > 0;
@@ -30,7 +30,7 @@ function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }
30
30
  }
31
31
  }
32
32
  // Tests depend on non-default export for mocking.
33
- function cliDocsVersionCommand(version, siteDir, pluginId, options) {
33
+ async function cliDocsVersionCommand(version, siteDir, pluginId, options) {
34
34
  // It wouldn't be very user-friendly to show a [default] log prefix,
35
35
  // so we use [docs] instead of [default]
36
36
  const pluginIdLogPrefix = pluginId === utils_1.DEFAULT_PLUGIN_ID ? '[docs]' : `[${pluginId}]`;
@@ -73,7 +73,7 @@ function cliDocsVersionCommand(version, siteDir, pluginId, options) {
73
73
  else {
74
74
  throw new Error(`${pluginIdLogPrefix}: there is no docs to version!`);
75
75
  }
76
- createVersionedSidebarFile({
76
+ await createVersionedSidebarFile({
77
77
  siteDir,
78
78
  pluginId,
79
79
  version,
package/lib/index.js CHANGED
@@ -214,7 +214,7 @@ async function pluginContentDocs(context, options) {
214
214
  function createMDXLoaderRule() {
215
215
  const contentDirs = versionsMetadata.flatMap(versions_1.getDocsDirPaths);
216
216
  return {
217
- test: /(\.mdx?)$/,
217
+ test: /\.mdx?$/i,
218
218
  include: contentDirs
219
219
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
220
220
  .map(utils_1.addTrailingPathSeparator),
package/lib/lastUpdate.js CHANGED
@@ -10,20 +10,21 @@ exports.getFileLastUpdate = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
12
12
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
- const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+),(.+)$/;
13
+ const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(?<timestamp>\d+),(?<author>.+)$/;
14
14
  let showedGitRequirementError = false;
15
15
  async function getFileLastUpdate(filePath) {
16
16
  if (!filePath) {
17
17
  return null;
18
18
  }
19
19
  function getTimestampAndAuthor(str) {
20
+ var _a;
20
21
  if (!str) {
21
22
  return null;
22
23
  }
23
- const temp = str.match(GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX);
24
- return !temp || temp.length < 3
25
- ? null
26
- : { timestamp: +temp[1], author: temp[2] };
24
+ const temp = (_a = str.match(GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX)) === null || _a === void 0 ? void 0 : _a.groups;
25
+ return temp
26
+ ? { timestamp: Number(temp.timestamp), author: temp.author }
27
+ : null;
27
28
  }
28
29
  // Wrap in try/catch in case the shell commands fail
29
30
  // (e.g. project doesn't use Git, etc).
@@ -10,13 +10,13 @@ exports.stripPathNumberPrefixes = exports.stripNumberPrefix = exports.DisabledNu
10
10
  // Best-effort to avoid parsing some patterns as number prefix
11
11
  const IgnoredPrefixPatterns = (() => {
12
12
  // ignore common date-like patterns: https://github.com/facebook/docusaurus/issues/4640
13
- const DateLikePrefixRegex = /^((\d{2}|\d{4})[-_.]\d{2}([-_.](\d{2}|\d{4}))?)(.*)$/;
13
+ const DateLikePrefixRegex = /^(?:\d{2}|\d{4})[-_.]\d{2}(?:[-_.](?:\d{2}|\d{4}))?.*$/;
14
14
  // ignore common versioning patterns: https://github.com/facebook/docusaurus/issues/4653
15
15
  // note: we could try to parse float numbers in filenames but that is
16
16
  // probably not worth it as a version such as "8.0" can be interpreted as both
17
17
  // a version and a float. User can configure her own NumberPrefixParser if
18
18
  // she wants 8.0 to be interpreted as a float
19
- const VersionLikePrefixRegex = /^(\d+[-_.]\d+)(.*)$/;
19
+ const VersionLikePrefixRegex = /^\d+[-_.]\d+.*$/;
20
20
  return new RegExp(`${DateLikePrefixRegex.source}|${VersionLikePrefixRegex.source}`);
21
21
  })();
22
22
  const NumberPrefixRegex = /^(?<numberPrefix>\d+)(?<separator>\s*[-_.]+\s*)(?<suffix>.*)$/;
@@ -11,6 +11,6 @@ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
11
11
  export declare const DefaultSidebars: SidebarsConfig;
12
12
  export declare const DisabledSidebars: SidebarsConfig;
13
13
  export declare function resolveSidebarPathOption(siteDir: string, sidebarPathOption: PluginOptions['sidebarPath']): PluginOptions['sidebarPath'];
14
- export declare function loadSidebarsFile(sidebarFilePath: string | false | undefined): SidebarsConfig;
15
- export declare function loadNormalizedSidebars(sidebarFilePath: string | false | undefined, params: NormalizeSidebarsParams): NormalizedSidebars;
14
+ export declare function loadSidebarsFile(sidebarFilePath: string | false | undefined): Promise<SidebarsConfig>;
15
+ export declare function loadNormalizedSidebars(sidebarFilePath: string | false | undefined, params: NormalizeSidebarsParams): Promise<NormalizedSidebars>;
16
16
  export declare function loadSidebars(sidebarFilePath: string | false | undefined, options: SidebarProcessorParams): Promise<Sidebars>;
@@ -32,7 +32,7 @@ function resolveSidebarPathOption(siteDir, sidebarPathOption) {
32
32
  : sidebarPathOption;
33
33
  }
34
34
  exports.resolveSidebarPathOption = resolveSidebarPathOption;
35
- function loadSidebarsFileUnsafe(sidebarFilePath) {
35
+ async function loadSidebarsFileUnsafe(sidebarFilePath) {
36
36
  // false => no sidebars
37
37
  if (sidebarFilePath === false) {
38
38
  return exports.DisabledSidebars;
@@ -50,14 +50,14 @@ function loadSidebarsFileUnsafe(sidebarFilePath) {
50
50
  // We don't want sidebars to be cached because of hot reloading.
51
51
  return (0, import_fresh_1.default)(sidebarFilePath);
52
52
  }
53
- function loadSidebarsFile(sidebarFilePath) {
54
- const sidebarsConfig = loadSidebarsFileUnsafe(sidebarFilePath);
53
+ async function loadSidebarsFile(sidebarFilePath) {
54
+ const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
55
55
  (0, validation_1.validateSidebars)(sidebarsConfig);
56
56
  return sidebarsConfig;
57
57
  }
58
58
  exports.loadSidebarsFile = loadSidebarsFile;
59
- function loadNormalizedSidebars(sidebarFilePath, params) {
60
- return (0, normalization_1.normalizeSidebars)(loadSidebarsFile(sidebarFilePath), params);
59
+ async function loadNormalizedSidebars(sidebarFilePath, params) {
60
+ return (0, normalization_1.normalizeSidebars)(await loadSidebarsFile(sidebarFilePath), params);
61
61
  }
62
62
  exports.loadNormalizedSidebars = loadNormalizedSidebars;
63
63
  // Note: sidebarFilePath must be absolute, use resolveSidebarPathOption
@@ -67,7 +67,7 @@ async function loadSidebars(sidebarFilePath, options) {
67
67
  version: options.version,
68
68
  categoryLabelSlugger: (0, utils_1.createSlugger)(),
69
69
  };
70
- const normalizedSidebars = loadNormalizedSidebars(sidebarFilePath, normalizeSidebarsParams);
70
+ const normalizedSidebars = await loadNormalizedSidebars(sidebarFilePath, normalizeSidebarsParams);
71
71
  return (0, processor_1.processSidebars)(normalizedSidebars, options);
72
72
  }
73
73
  exports.loadSidebars = loadSidebars;
@@ -20,7 +20,7 @@ const sidebarItemAutogeneratedSchema = sidebarItemBaseSchema.append({
20
20
  type: 'autogenerated',
21
21
  dirName: utils_validation_1.Joi.string()
22
22
  .required()
23
- .pattern(/^[^/](.*[^/])?$/)
23
+ .pattern(/^[^/](?:.*[^/])?$/)
24
24
  .message('"dirName" must be a dir path relative to the docs folder root, and should not start or end with slash'),
25
25
  });
26
26
  const sidebarItemDocSchema = sidebarItemBaseSchema.append({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4524",
3
+ "version": "0.0.0-4531",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@docusaurus/core": "0.0.0-4524",
26
- "@docusaurus/logger": "0.0.0-4524",
27
- "@docusaurus/mdx-loader": "0.0.0-4524",
28
- "@docusaurus/utils": "0.0.0-4524",
29
- "@docusaurus/utils-validation": "0.0.0-4524",
25
+ "@docusaurus/core": "0.0.0-4531",
26
+ "@docusaurus/logger": "0.0.0-4531",
27
+ "@docusaurus/mdx-loader": "0.0.0-4531",
28
+ "@docusaurus/utils": "0.0.0-4531",
29
+ "@docusaurus/utils-validation": "0.0.0-4531",
30
30
  "combine-promises": "^1.1.0",
31
31
  "fs-extra": "^10.0.0",
32
32
  "import-fresh": "^3.2.2",
@@ -36,11 +36,11 @@
36
36
  "shelljs": "^0.8.4",
37
37
  "tslib": "^2.3.1",
38
38
  "utility-types": "^3.10.0",
39
- "webpack": "^5.61.0"
39
+ "webpack": "^5.68.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4524",
43
- "@docusaurus/types": "0.0.0-4524",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4531",
43
+ "@docusaurus/types": "0.0.0-4531",
44
44
  "@types/js-yaml": "^4.0.0",
45
45
  "@types/picomatch": "^2.2.1",
46
46
  "commander": "^5.1.0",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=14"
58
58
  },
59
- "gitHead": "41a6bff3a67446f7d2a2972cbe4d05fec7378a15"
59
+ "gitHead": "fe104fed3e8ef603f81594311564e598c9c55a6c"
60
60
  }
package/src/cli.ts CHANGED
@@ -20,7 +20,7 @@ import {loadSidebarsFile, resolveSidebarPathOption} from './sidebars';
20
20
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
21
21
  import logger from '@docusaurus/logger';
22
22
 
23
- function createVersionedSidebarFile({
23
+ async function createVersionedSidebarFile({
24
24
  siteDir,
25
25
  pluginId,
26
26
  sidebarPath,
@@ -34,7 +34,7 @@ function createVersionedSidebarFile({
34
34
  // Load current sidebar and create a new versioned sidebars file (if needed).
35
35
  // Note: we don't need the sidebars file to be normalized: it's ok to let
36
36
  // plugin option changes to impact older, versioned sidebars
37
- const sidebars = loadSidebarsFile(sidebarPath);
37
+ const sidebars = await loadSidebarsFile(sidebarPath);
38
38
 
39
39
  // Do not create a useless versioned sidebars file if sidebars file is empty
40
40
  // or sidebars are disabled/false)
@@ -56,12 +56,12 @@ function createVersionedSidebarFile({
56
56
  }
57
57
 
58
58
  // Tests depend on non-default export for mocking.
59
- export function cliDocsVersionCommand(
59
+ export async function cliDocsVersionCommand(
60
60
  version: string | null | undefined,
61
61
  siteDir: string,
62
62
  pluginId: string,
63
63
  options: PathOptions & SidebarOptions,
64
- ): void {
64
+ ): Promise<void> {
65
65
  // It wouldn't be very user-friendly to show a [default] log prefix,
66
66
  // so we use [docs] instead of [default]
67
67
  const pluginIdLogPrefix =
@@ -127,7 +127,7 @@ export function cliDocsVersionCommand(
127
127
  throw new Error(`${pluginIdLogPrefix}: there is no docs to version!`);
128
128
  }
129
129
 
130
- createVersionedSidebarFile({
130
+ await createVersionedSidebarFile({
131
131
  siteDir,
132
132
  pluginId,
133
133
  version,
package/src/index.ts CHANGED
@@ -333,7 +333,7 @@ export default async function pluginContentDocs(
333
333
  function createMDXLoaderRule(): RuleSetRule {
334
334
  const contentDirs = versionsMetadata.flatMap(getDocsDirPaths);
335
335
  return {
336
- test: /(\.mdx?)$/,
336
+ test: /\.mdx?$/i,
337
337
  include: contentDirs
338
338
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
339
339
  .map(addTrailingPathSeparator),
package/src/lastUpdate.ts CHANGED
@@ -10,7 +10,7 @@ import logger from '@docusaurus/logger';
10
10
 
11
11
  type FileLastUpdateData = {timestamp?: number; author?: string};
12
12
 
13
- const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(\d+),(.+)$/;
13
+ const GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX = /^(?<timestamp>\d+),(?<author>.+)$/;
14
14
 
15
15
  let showedGitRequirementError = false;
16
16
 
@@ -25,10 +25,10 @@ export async function getFileLastUpdate(
25
25
  return null;
26
26
  }
27
27
 
28
- const temp = str.match(GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX);
29
- return !temp || temp.length < 3
30
- ? null
31
- : {timestamp: +temp[1], author: temp[2]};
28
+ const temp = str.match(GIT_COMMIT_TIMESTAMP_AUTHOR_REGEX)?.groups;
29
+ return temp
30
+ ? {timestamp: Number(temp.timestamp), author: temp.author}
31
+ : null;
32
32
  }
33
33
 
34
34
  // Wrap in try/catch in case the shell commands fail
@@ -11,14 +11,14 @@ import type {NumberPrefixParser} from '@docusaurus/plugin-content-docs';
11
11
  const IgnoredPrefixPatterns = (() => {
12
12
  // ignore common date-like patterns: https://github.com/facebook/docusaurus/issues/4640
13
13
  const DateLikePrefixRegex =
14
- /^((\d{2}|\d{4})[-_.]\d{2}([-_.](\d{2}|\d{4}))?)(.*)$/;
14
+ /^(?:\d{2}|\d{4})[-_.]\d{2}(?:[-_.](?:\d{2}|\d{4}))?.*$/;
15
15
 
16
16
  // ignore common versioning patterns: https://github.com/facebook/docusaurus/issues/4653
17
17
  // note: we could try to parse float numbers in filenames but that is
18
18
  // probably not worth it as a version such as "8.0" can be interpreted as both
19
19
  // a version and a float. User can configure her own NumberPrefixParser if
20
20
  // she wants 8.0 to be interpreted as a float
21
- const VersionLikePrefixRegex = /^(\d+[-_.]\d+)(.*)$/;
21
+ const VersionLikePrefixRegex = /^\d+[-_.]\d+.*$/;
22
22
 
23
23
  return new RegExp(
24
24
  `${DateLikePrefixRegex.source}|${VersionLikePrefixRegex.source}`,
@@ -38,9 +38,9 @@ export function resolveSidebarPathOption(
38
38
  : sidebarPathOption;
39
39
  }
40
40
 
41
- function loadSidebarsFileUnsafe(
41
+ async function loadSidebarsFileUnsafe(
42
42
  sidebarFilePath: string | false | undefined,
43
- ): SidebarsConfig {
43
+ ): Promise<SidebarsConfig> {
44
44
  // false => no sidebars
45
45
  if (sidebarFilePath === false) {
46
46
  return DisabledSidebars;
@@ -62,19 +62,19 @@ function loadSidebarsFileUnsafe(
62
62
  return importFresh(sidebarFilePath);
63
63
  }
64
64
 
65
- export function loadSidebarsFile(
65
+ export async function loadSidebarsFile(
66
66
  sidebarFilePath: string | false | undefined,
67
- ): SidebarsConfig {
68
- const sidebarsConfig = loadSidebarsFileUnsafe(sidebarFilePath);
67
+ ): Promise<SidebarsConfig> {
68
+ const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
69
69
  validateSidebars(sidebarsConfig);
70
70
  return sidebarsConfig;
71
71
  }
72
72
 
73
- export function loadNormalizedSidebars(
73
+ export async function loadNormalizedSidebars(
74
74
  sidebarFilePath: string | false | undefined,
75
75
  params: NormalizeSidebarsParams,
76
- ): NormalizedSidebars {
77
- return normalizeSidebars(loadSidebarsFile(sidebarFilePath), params);
76
+ ): Promise<NormalizedSidebars> {
77
+ return normalizeSidebars(await loadSidebarsFile(sidebarFilePath), params);
78
78
  }
79
79
 
80
80
  // Note: sidebarFilePath must be absolute, use resolveSidebarPathOption
@@ -87,7 +87,7 @@ export async function loadSidebars(
87
87
  version: options.version,
88
88
  categoryLabelSlugger: createSlugger(),
89
89
  };
90
- const normalizedSidebars = loadNormalizedSidebars(
90
+ const normalizedSidebars = await loadNormalizedSidebars(
91
91
  sidebarFilePath,
92
92
  normalizeSidebarsParams,
93
93
  );
@@ -36,7 +36,7 @@ const sidebarItemAutogeneratedSchema =
36
36
  type: 'autogenerated',
37
37
  dirName: Joi.string()
38
38
  .required()
39
- .pattern(/^[^/](.*[^/])?$/)
39
+ .pattern(/^[^/](?:.*[^/])?$/)
40
40
  .message(
41
41
  '"dirName" must be a dir path relative to the docs folder root, and should not start or end with slash',
42
42
  ),