@docusaurus/plugin-content-docs 4.0.0-canary-6884 → 4.0.0-canary-6888
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.js +13 -8
- package/lib/docs.js +3 -2
- package/lib/index.js +3 -3
- package/lib/sidebars/index.js +4 -3
- package/lib/versions/files.js +5 -5
- package/package.json +13 -13
- package/src/cli.ts +12 -7
- package/src/docs.ts +5 -2
- package/src/index.ts +2 -2
- package/src/sidebars/index.ts +3 -2
- package/src/versions/files.ts +5 -5
package/lib/cli.js
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const
|
|
10
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
11
11
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
|
+
const fs_1 = require("@docusaurus/fs");
|
|
14
15
|
const files_1 = require("./versions/files");
|
|
15
16
|
const validation_1 = require("./versions/validation");
|
|
16
17
|
const sidebars_1 = require("./sidebars");
|
|
@@ -25,7 +26,7 @@ async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, vers
|
|
|
25
26
|
// or sidebars are disabled/false)
|
|
26
27
|
const shouldCreateVersionedSidebarFile = Object.keys(sidebars).length > 0;
|
|
27
28
|
if (shouldCreateVersionedSidebarFile) {
|
|
28
|
-
await
|
|
29
|
+
await (0, fs_1.outputFile)((0, files_1.getVersionSidebarsPath)(siteDir, pluginId, version), `${JSON.stringify(sidebars, null, 2)}\n`, 'utf8');
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
// Tests depend on non-default export for mocking.
|
|
@@ -58,8 +59,8 @@ async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, si
|
|
|
58
59
|
pluginId,
|
|
59
60
|
versionName: constants_1.CURRENT_VERSION_NAME,
|
|
60
61
|
});
|
|
61
|
-
if (!(await
|
|
62
|
-
(await
|
|
62
|
+
if (!(await (0, fs_1.pathExists)(docsDir)) ||
|
|
63
|
+
(await promises_1.default.readdir(docsDir)).length === 0) {
|
|
63
64
|
if (locale === i18n.defaultLocale) {
|
|
64
65
|
throw new Error(logger_1.default.interpolate `${pluginIdLogPrefix}: no docs found in path=${docsDir}.`);
|
|
65
66
|
}
|
|
@@ -75,7 +76,11 @@ async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, si
|
|
|
75
76
|
pluginId,
|
|
76
77
|
versionName: version,
|
|
77
78
|
});
|
|
78
|
-
|
|
79
|
+
// verbatimSymlinks: keep relative symlinks relative
|
|
80
|
+
await promises_1.default.cp(docsDir, newVersionDir, {
|
|
81
|
+
recursive: true,
|
|
82
|
+
verbatimSymlinks: true,
|
|
83
|
+
});
|
|
79
84
|
// Copy version JSON translation file for this locale
|
|
80
85
|
// i18n/<l>/docusaurus-plugin-content-docs/current.json => version-v1.json
|
|
81
86
|
// See https://docusaurus.io/docs/next/api/plugins/@docusaurus/plugin-content-docs#translation-files-location
|
|
@@ -86,8 +91,8 @@ async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, si
|
|
|
86
91
|
});
|
|
87
92
|
const sourceFile = node_path_1.default.join(dir, 'current.json');
|
|
88
93
|
const dest = node_path_1.default.join(dir, `version-${version}.json`);
|
|
89
|
-
if (await
|
|
90
|
-
await
|
|
94
|
+
if (await (0, fs_1.pathExists)(sourceFile)) {
|
|
95
|
+
await promises_1.default.cp(sourceFile, dest, { verbatimSymlinks: true });
|
|
91
96
|
}
|
|
92
97
|
else {
|
|
93
98
|
logger_1.default.warn `${pluginIdLogPrefix}: i18n translation file does not exist in path=${sourceFile}. Skipping.`;
|
|
@@ -102,7 +107,7 @@ async function cliDocsVersionCommand(version, { id: pluginId, path: docsPath, si
|
|
|
102
107
|
});
|
|
103
108
|
// Update versions.json file.
|
|
104
109
|
versions.unshift(version);
|
|
105
|
-
await
|
|
110
|
+
await (0, fs_1.outputFile)((0, files_1.getVersionsFilePath)(siteDir, pluginId), `${JSON.stringify(versions, null, 2)}\n`);
|
|
106
111
|
logger_1.default.success `name=${pluginIdLogPrefix}: version name=${version} created!`;
|
|
107
112
|
}
|
|
108
113
|
// TODO try to remove this workaround
|
package/lib/docs.js
CHANGED
|
@@ -16,10 +16,11 @@ exports.toCategoryIndexMatcherParam = toCategoryIndexMatcherParam;
|
|
|
16
16
|
exports.createDocsByIdIndex = createDocsByIdIndex;
|
|
17
17
|
const tslib_1 = require("tslib");
|
|
18
18
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
19
|
-
const
|
|
19
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
20
20
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
21
21
|
const utils_1 = require("@docusaurus/utils");
|
|
22
22
|
const glob_1 = require("@docusaurus/glob");
|
|
23
|
+
const fs_1 = require("@docusaurus/fs");
|
|
23
24
|
const frontMatter_1 = require("./frontMatter");
|
|
24
25
|
const slug_1 = tslib_1.__importDefault(require("./slug"));
|
|
25
26
|
const numberPrefix_1 = require("./numberPrefix");
|
|
@@ -27,7 +28,7 @@ const utils_2 = require("./sidebars/utils");
|
|
|
27
28
|
async function readDocFile(versionMetadata, source) {
|
|
28
29
|
const contentPath = await (0, utils_1.getFolderContainingFile)((0, utils_1.getContentPathList)(versionMetadata), source);
|
|
29
30
|
const filePath = node_path_1.default.join(contentPath, source);
|
|
30
|
-
const content = await
|
|
31
|
+
const content = await (0, fs_1.queueFileOperation)(() => promises_1.default.readFile(filePath, 'utf-8'));
|
|
31
32
|
return { source, content, contentPath, filePath };
|
|
32
33
|
}
|
|
33
34
|
async function readVersionDocs(versionMetadata, options) {
|
package/lib/index.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.validateOptions = void 0;
|
|
|
10
10
|
exports.default = pluginContentDocs;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
|
-
const
|
|
13
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
15
15
|
const glob_1 = require("@docusaurus/glob");
|
|
16
16
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
@@ -41,8 +41,8 @@ async function createMdxLoaderDependencyFile({ dataDir, options, versionsMetadat
|
|
|
41
41
|
options,
|
|
42
42
|
versionsMetadata,
|
|
43
43
|
};
|
|
44
|
-
await
|
|
45
|
-
await
|
|
44
|
+
await promises_1.default.mkdir(dataDir, { recursive: true });
|
|
45
|
+
await promises_1.default.writeFile(filePath, JSON.stringify(fileContent));
|
|
46
46
|
return filePath;
|
|
47
47
|
}
|
|
48
48
|
async function pluginContentDocs(context, options) {
|
package/lib/sidebars/index.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.resolveSidebarPathOption = resolveSidebarPathOption;
|
|
|
11
11
|
exports.loadSidebarsFile = loadSidebarsFile;
|
|
12
12
|
exports.loadSidebars = loadSidebars;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
|
-
const
|
|
14
|
+
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
15
15
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
16
16
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
17
17
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -19,6 +19,7 @@ const utils_1 = require("@docusaurus/utils");
|
|
|
19
19
|
const glob_1 = require("@docusaurus/glob");
|
|
20
20
|
const Yaml = tslib_1.__importStar(require("js-yaml"));
|
|
21
21
|
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
22
|
+
const fs_1 = require("@docusaurus/fs");
|
|
22
23
|
const validation_1 = require("./validation");
|
|
23
24
|
const normalization_1 = require("./normalization");
|
|
24
25
|
const processor_1 = require("./processor");
|
|
@@ -48,7 +49,7 @@ async function readCategoriesMetadata(contentPath) {
|
|
|
48
49
|
if (files.length > 1) {
|
|
49
50
|
logger_1.default.warn `There are more than one category metadata files for path=${folder}: ${files.join(', ')}. The behavior is undetermined.`;
|
|
50
51
|
}
|
|
51
|
-
const content = await
|
|
52
|
+
const content = await promises_1.default.readFile(node_path_1.default.join(contentPath, filePath), 'utf-8');
|
|
52
53
|
try {
|
|
53
54
|
return (0, validation_1.validateCategoryMetadataFile)(Yaml.load(content));
|
|
54
55
|
}
|
|
@@ -70,7 +71,7 @@ async function loadSidebarsFileUnsafe(sidebarFilePath) {
|
|
|
70
71
|
// Non-existent sidebars file: no sidebars
|
|
71
72
|
// Note: this edge case can happen on versioned docs, not current version
|
|
72
73
|
// We avoid creating empty versioned sidebars file with the CLI
|
|
73
|
-
if (!(await
|
|
74
|
+
if (!(await (0, fs_1.pathExists)(sidebarFilePath))) {
|
|
74
75
|
return exports.DisabledSidebars;
|
|
75
76
|
}
|
|
76
77
|
// We don't want sidebars to be cached because of hot reloading.
|
package/lib/versions/files.js
CHANGED
|
@@ -16,8 +16,8 @@ exports.readVersionNames = readVersionNames;
|
|
|
16
16
|
exports.getVersionMetadataPaths = getVersionMetadataPaths;
|
|
17
17
|
const tslib_1 = require("tslib");
|
|
18
18
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
19
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
20
19
|
const utils_1 = require("@docusaurus/utils");
|
|
20
|
+
const fs_1 = require("@docusaurus/fs");
|
|
21
21
|
const constants_1 = require("../constants");
|
|
22
22
|
const validation_1 = require("./validation");
|
|
23
23
|
/** Add a prefix like `community_version-1.0.0`. No-op for default instance. */
|
|
@@ -66,8 +66,8 @@ function getVersionsFilePath(siteDir, pluginId) {
|
|
|
66
66
|
*/
|
|
67
67
|
async function readVersionsFile(siteDir, pluginId) {
|
|
68
68
|
const versionsFilePath = getVersionsFilePath(siteDir, pluginId);
|
|
69
|
-
if (await
|
|
70
|
-
const content = await
|
|
69
|
+
if (await (0, fs_1.pathExists)(versionsFilePath)) {
|
|
70
|
+
const content = await (0, fs_1.readJSON)(versionsFilePath);
|
|
71
71
|
(0, validation_1.validateVersionNames)(content);
|
|
72
72
|
return content;
|
|
73
73
|
}
|
|
@@ -131,7 +131,7 @@ async function getVersionMetadataPaths({ versionName, context, options, }) {
|
|
|
131
131
|
const sidebarFilePath = isCurrent
|
|
132
132
|
? options.sidebarPath
|
|
133
133
|
: getVersionSidebarsPath(context.siteDir, options.id, versionName);
|
|
134
|
-
if (!(await
|
|
134
|
+
if (!(await (0, fs_1.pathExists)(contentPath))) {
|
|
135
135
|
throw new Error(`The docs folder does not exist for version "${versionName}". A docs folder is expected to be found at ${node_path_1.default.relative(context.siteDir, contentPath)}.`);
|
|
136
136
|
}
|
|
137
137
|
// If the current version defines a path to a sidebar file that does not
|
|
@@ -141,7 +141,7 @@ async function getVersionMetadataPaths({ versionName, context, options, }) {
|
|
|
141
141
|
// See https://github.com/facebook/docusaurus/pull/4775
|
|
142
142
|
if (versionName === constants_1.CURRENT_VERSION_NAME &&
|
|
143
143
|
typeof sidebarFilePath === 'string' &&
|
|
144
|
-
!(await
|
|
144
|
+
!(await (0, fs_1.pathExists)(sidebarFilePath))) {
|
|
145
145
|
throw new Error(`The path to the sidebar file does not exist at "${node_path_1.default.relative(context.siteDir, sidebarFilePath)}".
|
|
146
146
|
Please set the docs "sidebarPath" field in your config file to:
|
|
147
147
|
- a sidebars path that exists
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6888",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "4.0.0-canary-
|
|
39
|
-
"@docusaurus/
|
|
40
|
-
"@docusaurus/
|
|
41
|
-
"@docusaurus/
|
|
42
|
-
"@docusaurus/
|
|
43
|
-
"@docusaurus/
|
|
44
|
-
"@docusaurus/
|
|
45
|
-
"@docusaurus/
|
|
46
|
-
"@docusaurus/utils
|
|
47
|
-
"@docusaurus/utils-
|
|
38
|
+
"@docusaurus/core": "4.0.0-canary-6888",
|
|
39
|
+
"@docusaurus/fs": "4.0.0-canary-6888",
|
|
40
|
+
"@docusaurus/glob": "4.0.0-canary-6888",
|
|
41
|
+
"@docusaurus/logger": "4.0.0-canary-6888",
|
|
42
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6888",
|
|
43
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6888",
|
|
44
|
+
"@docusaurus/theme-common": "4.0.0-canary-6888",
|
|
45
|
+
"@docusaurus/types": "4.0.0-canary-6888",
|
|
46
|
+
"@docusaurus/utils": "4.0.0-canary-6888",
|
|
47
|
+
"@docusaurus/utils-common": "4.0.0-canary-6888",
|
|
48
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6888",
|
|
48
49
|
"@types/react-router-config": "^5.0.11",
|
|
49
50
|
"combine-promises": "^1.2.0",
|
|
50
|
-
"fs-extra": "^11.4.0",
|
|
51
51
|
"js-yaml": "^5.4.1",
|
|
52
52
|
"lodash": "^4.18.1",
|
|
53
53
|
"schema-dts": "^1.1.5",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=24.21"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "5019a662590dcb2722926890c1ade27194bc3b70"
|
|
73
73
|
}
|
package/src/cli.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import fs from 'fs
|
|
8
|
+
import fs from 'node:fs/promises';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import logger from '@docusaurus/logger';
|
|
11
11
|
import {DEFAULT_PLUGIN_ID, getLocaleConfig} from '@docusaurus/utils';
|
|
12
|
+
import {pathExists, outputFile} from '@docusaurus/fs';
|
|
12
13
|
import {
|
|
13
14
|
getVersionsFilePath,
|
|
14
15
|
getVersionDocsDirPath,
|
|
@@ -45,7 +46,7 @@ async function createVersionedSidebarFile({
|
|
|
45
46
|
const shouldCreateVersionedSidebarFile = Object.keys(sidebars).length > 0;
|
|
46
47
|
|
|
47
48
|
if (shouldCreateVersionedSidebarFile) {
|
|
48
|
-
await
|
|
49
|
+
await outputFile(
|
|
49
50
|
getVersionSidebarsPath(siteDir, pluginId, version),
|
|
50
51
|
`${JSON.stringify(sidebars, null, 2)}\n`,
|
|
51
52
|
'utf8',
|
|
@@ -102,7 +103,7 @@ async function cliDocsVersionCommand(
|
|
|
102
103
|
});
|
|
103
104
|
|
|
104
105
|
if (
|
|
105
|
-
!(await
|
|
106
|
+
!(await pathExists(docsDir)) ||
|
|
106
107
|
(await fs.readdir(docsDir)).length === 0
|
|
107
108
|
) {
|
|
108
109
|
if (locale === i18n.defaultLocale) {
|
|
@@ -123,7 +124,11 @@ async function cliDocsVersionCommand(
|
|
|
123
124
|
pluginId,
|
|
124
125
|
versionName: version,
|
|
125
126
|
});
|
|
126
|
-
|
|
127
|
+
// verbatimSymlinks: keep relative symlinks relative
|
|
128
|
+
await fs.cp(docsDir, newVersionDir, {
|
|
129
|
+
recursive: true,
|
|
130
|
+
verbatimSymlinks: true,
|
|
131
|
+
});
|
|
127
132
|
|
|
128
133
|
// Copy version JSON translation file for this locale
|
|
129
134
|
// i18n/<l>/docusaurus-plugin-content-docs/current.json => version-v1.json
|
|
@@ -135,8 +140,8 @@ async function cliDocsVersionCommand(
|
|
|
135
140
|
});
|
|
136
141
|
const sourceFile = path.join(dir, 'current.json');
|
|
137
142
|
const dest = path.join(dir, `version-${version}.json`);
|
|
138
|
-
if (await
|
|
139
|
-
await fs.
|
|
143
|
+
if (await pathExists(sourceFile)) {
|
|
144
|
+
await fs.cp(sourceFile, dest, {verbatimSymlinks: true});
|
|
140
145
|
} else {
|
|
141
146
|
logger.warn`${pluginIdLogPrefix}: i18n translation file does not exist in path=${sourceFile}. Skipping.`;
|
|
142
147
|
}
|
|
@@ -153,7 +158,7 @@ async function cliDocsVersionCommand(
|
|
|
153
158
|
|
|
154
159
|
// Update versions.json file.
|
|
155
160
|
versions.unshift(version);
|
|
156
|
-
await
|
|
161
|
+
await outputFile(
|
|
157
162
|
getVersionsFilePath(siteDir, pluginId),
|
|
158
163
|
`${JSON.stringify(versions, null, 2)}\n`,
|
|
159
164
|
);
|
package/src/docs.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
import fs from 'fs
|
|
9
|
+
import fs from 'node:fs/promises';
|
|
10
10
|
import _ from 'lodash';
|
|
11
11
|
import {
|
|
12
12
|
aliasedSitePath,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
normalizeTags,
|
|
23
23
|
} from '@docusaurus/utils';
|
|
24
24
|
import {glob} from '@docusaurus/glob';
|
|
25
|
+
import {queueFileOperation} from '@docusaurus/fs';
|
|
25
26
|
import {validateDocFrontMatter} from './frontMatter';
|
|
26
27
|
import getSlug from './slug';
|
|
27
28
|
import {stripPathNumberPrefixes} from './numberPrefix';
|
|
@@ -55,7 +56,9 @@ export async function readDocFile(
|
|
|
55
56
|
|
|
56
57
|
const filePath = path.join(contentPath, source);
|
|
57
58
|
|
|
58
|
-
const content = await
|
|
59
|
+
const content = await queueFileOperation(() =>
|
|
60
|
+
fs.readFile(filePath, 'utf-8'),
|
|
61
|
+
);
|
|
59
62
|
return {source, content, contentPath, filePath};
|
|
60
63
|
}
|
|
61
64
|
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
import fs from 'fs
|
|
9
|
+
import fs from 'node:fs/promises';
|
|
10
10
|
import {
|
|
11
11
|
normalizeUrl,
|
|
12
12
|
docuHash,
|
|
@@ -74,7 +74,7 @@ async function createMdxLoaderDependencyFile({
|
|
|
74
74
|
options,
|
|
75
75
|
versionsMetadata,
|
|
76
76
|
};
|
|
77
|
-
await fs.
|
|
77
|
+
await fs.mkdir(dataDir, {recursive: true});
|
|
78
78
|
await fs.writeFile(filePath, JSON.stringify(fileContent));
|
|
79
79
|
return filePath;
|
|
80
80
|
}
|
package/src/sidebars/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import fs from 'fs
|
|
8
|
+
import fs from 'node:fs/promises';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import _ from 'lodash';
|
|
11
11
|
import logger from '@docusaurus/logger';
|
|
@@ -13,6 +13,7 @@ import {loadFreshModule} from '@docusaurus/utils';
|
|
|
13
13
|
import {glob} from '@docusaurus/glob';
|
|
14
14
|
import * as Yaml from 'js-yaml';
|
|
15
15
|
import combinePromises from 'combine-promises';
|
|
16
|
+
import {pathExists} from '@docusaurus/fs';
|
|
16
17
|
import {validateSidebars, validateCategoryMetadataFile} from './validation';
|
|
17
18
|
import {normalizeSidebars} from './normalization';
|
|
18
19
|
import {processSidebars} from './processor';
|
|
@@ -84,7 +85,7 @@ async function loadSidebarsFileUnsafe(
|
|
|
84
85
|
// Non-existent sidebars file: no sidebars
|
|
85
86
|
// Note: this edge case can happen on versioned docs, not current version
|
|
86
87
|
// We avoid creating empty versioned sidebars file with the CLI
|
|
87
|
-
if (!(await
|
|
88
|
+
if (!(await pathExists(sidebarFilePath))) {
|
|
88
89
|
return DisabledSidebars;
|
|
89
90
|
}
|
|
90
91
|
|
package/src/versions/files.ts
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
import fs from 'fs-extra';
|
|
10
9
|
import {
|
|
11
10
|
getPluginI18nPath,
|
|
12
11
|
getLocaleConfig,
|
|
13
12
|
DEFAULT_PLUGIN_ID,
|
|
14
13
|
} from '@docusaurus/utils';
|
|
14
|
+
import {pathExists, readJSON} from '@docusaurus/fs';
|
|
15
15
|
import {
|
|
16
16
|
VERSIONS_JSON_FILE,
|
|
17
17
|
VERSIONED_DOCS_DIR,
|
|
@@ -110,8 +110,8 @@ export async function readVersionsFile(
|
|
|
110
110
|
pluginId: string,
|
|
111
111
|
): Promise<string[] | null> {
|
|
112
112
|
const versionsFilePath = getVersionsFilePath(siteDir, pluginId);
|
|
113
|
-
if (await
|
|
114
|
-
const content: unknown = await
|
|
113
|
+
if (await pathExists(versionsFilePath)) {
|
|
114
|
+
const content: unknown = await readJSON(versionsFilePath);
|
|
115
115
|
validateVersionNames(content);
|
|
116
116
|
return content;
|
|
117
117
|
}
|
|
@@ -207,7 +207,7 @@ export async function getVersionMetadataPaths({
|
|
|
207
207
|
? options.sidebarPath
|
|
208
208
|
: getVersionSidebarsPath(context.siteDir, options.id, versionName);
|
|
209
209
|
|
|
210
|
-
if (!(await
|
|
210
|
+
if (!(await pathExists(contentPath))) {
|
|
211
211
|
throw new Error(
|
|
212
212
|
`The docs folder does not exist for version "${versionName}". A docs folder is expected to be found at ${path.relative(
|
|
213
213
|
context.siteDir,
|
|
@@ -224,7 +224,7 @@ export async function getVersionMetadataPaths({
|
|
|
224
224
|
if (
|
|
225
225
|
versionName === CURRENT_VERSION_NAME &&
|
|
226
226
|
typeof sidebarFilePath === 'string' &&
|
|
227
|
-
!(await
|
|
227
|
+
!(await pathExists(sidebarFilePath))
|
|
228
228
|
) {
|
|
229
229
|
throw new Error(`The path to the sidebar file does not exist at "${path.relative(
|
|
230
230
|
context.siteDir,
|