@docusaurus/core 0.0.0-4511 → 0.0.0-4518
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/bin/beforeCli.js
CHANGED
|
@@ -20,105 +20,114 @@ const {
|
|
|
20
20
|
engines: {node: requiredVersion},
|
|
21
21
|
} = require('../package.json');
|
|
22
22
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
24
|
+
const sitePkg = require(path.resolve(process.cwd(), 'package.json'));
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Notify user if `@docusaurus` packages are outdated
|
|
28
|
+
*
|
|
29
|
+
* Note: this is a 2-step process to avoid delaying cli usage by awaiting a
|
|
30
|
+
* response:
|
|
31
|
+
* - 1st run: trigger background job to check releases + store result
|
|
32
|
+
* - 2nd run: display potential update to users
|
|
33
|
+
*
|
|
34
|
+
* cache data is stored in `~/.config/configstore/update-notifier-@docusaurus`
|
|
35
|
+
*/
|
|
36
|
+
function beforeCli() {
|
|
37
|
+
const notifier = updateNotifier({
|
|
38
|
+
pkg: {
|
|
39
|
+
name,
|
|
40
|
+
version,
|
|
41
|
+
},
|
|
42
|
+
// Check is in background so it's fine to use a small value like 1h
|
|
43
|
+
// Use 0 for debugging
|
|
44
|
+
updateCheckInterval: 1000 * 60 * 60,
|
|
45
|
+
// updateCheckInterval: 0
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Hacky way to ensure we check for updates on first run
|
|
49
|
+
// Note: the notification will only happen in the 2nd run
|
|
50
|
+
// See https://github.com/yeoman/update-notifier/issues/209
|
|
51
|
+
try {
|
|
52
|
+
if (
|
|
53
|
+
notifier.config &&
|
|
54
|
+
// @ts-expect-error: this is an internal API
|
|
55
|
+
!notifier.disabled &&
|
|
56
|
+
Date.now() - notifier.config.get('lastUpdateCheck') < 50
|
|
57
|
+
) {
|
|
58
|
+
notifier.config.set('lastUpdateCheck', 0);
|
|
59
|
+
notifier.check();
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// Do not stop cli if this fails, see https://github.com/facebook/docusaurus/issues/5400
|
|
63
|
+
logger.error(e);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* We don't want to display update message for canary releases.
|
|
68
|
+
* See https://github.com/facebook/docusaurus/issues/5378
|
|
69
|
+
* @param {import('update-notifier').UpdateInfo} update
|
|
70
|
+
*/
|
|
71
|
+
function ignoreUpdate(update) {
|
|
72
|
+
const isCanaryRelease =
|
|
73
|
+
update && update.current && update.current.startsWith('0.0.0');
|
|
74
|
+
return isCanaryRelease;
|
|
75
|
+
}
|
|
76
|
+
|
|
48
77
|
if (
|
|
49
78
|
notifier.config &&
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
notifier.update &&
|
|
80
|
+
semver.lt(notifier.update.current, notifier.update.latest)
|
|
52
81
|
) {
|
|
53
|
-
notifier
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Do not stop cli if this fails, see https://github.com/facebook/docusaurus/issues/5400
|
|
58
|
-
logger.error(e);
|
|
59
|
-
}
|
|
82
|
+
// Because notifier clears cached data after reading it, leading to notifier
|
|
83
|
+
// not consistently displaying the update.
|
|
84
|
+
// See https://github.com/yeoman/update-notifier/issues/209
|
|
85
|
+
notifier.config.set('update', notifier.update);
|
|
60
86
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const isCanaryRelease =
|
|
65
|
-
update && update.current && update.current.startsWith('0.0.0');
|
|
66
|
-
return isCanaryRelease;
|
|
67
|
-
}
|
|
87
|
+
if (ignoreUpdate(notifier.update)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
68
90
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
const siteDocusaurusPackagesForUpdate = Object.keys({
|
|
92
|
+
...sitePkg.dependencies,
|
|
93
|
+
...sitePkg.devDependencies,
|
|
94
|
+
})
|
|
95
|
+
.filter((p) => p.startsWith('@docusaurus'))
|
|
96
|
+
.map((p) => p.concat('@latest'))
|
|
97
|
+
.join(' ');
|
|
98
|
+
const isYarnUsed = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
|
|
99
|
+
const upgradeCommand = isYarnUsed
|
|
100
|
+
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
101
|
+
: `npm i ${siteDocusaurusPackagesForUpdate}`;
|
|
77
102
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
/** @type {import('boxen').Options} */
|
|
104
|
+
const boxenOptions = {
|
|
105
|
+
padding: 1,
|
|
106
|
+
margin: 1,
|
|
107
|
+
align: 'center',
|
|
108
|
+
borderColor: 'yellow',
|
|
109
|
+
borderStyle: 'round',
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const docusaurusUpdateMessage = boxen(
|
|
113
|
+
`Update available ${logger.dim(
|
|
114
|
+
`${notifier.update.current}`,
|
|
115
|
+
)} → ${logger.green(`${notifier.update.latest}`)}
|
|
116
|
+
|
|
117
|
+
To upgrade Docusaurus packages with the latest version, run the following command:
|
|
118
|
+
${logger.code(upgradeCommand)}`,
|
|
119
|
+
boxenOptions,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
console.log(docusaurusUpdateMessage);
|
|
81
123
|
}
|
|
82
124
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
.filter((p) => p.startsWith('@docusaurus'))
|
|
90
|
-
.map((p) => p.concat('@latest'))
|
|
91
|
-
.join(' ');
|
|
92
|
-
const isYarnUsed = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
|
|
93
|
-
const upgradeCommand = isYarnUsed
|
|
94
|
-
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
95
|
-
: `npm i ${siteDocusaurusPackagesForUpdate}`;
|
|
96
|
-
|
|
97
|
-
/** @type {import('boxen').Options} */
|
|
98
|
-
const boxenOptions = {
|
|
99
|
-
padding: 1,
|
|
100
|
-
margin: 1,
|
|
101
|
-
align: 'center',
|
|
102
|
-
borderColor: 'yellow',
|
|
103
|
-
borderStyle: 'round',
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const docusaurusUpdateMessage = boxen(
|
|
107
|
-
`Update available ${logger.dim(
|
|
108
|
-
`${notifier.update.current}`,
|
|
109
|
-
)} → ${logger.green(`${notifier.update.latest}`)}
|
|
110
|
-
|
|
111
|
-
To upgrade Docusaurus packages with the latest version, run the following command:
|
|
112
|
-
${logger.code(upgradeCommand)}`,
|
|
113
|
-
boxenOptions,
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
console.log(docusaurusUpdateMessage);
|
|
125
|
+
// notify user if node version needs to be updated
|
|
126
|
+
if (!semver.satisfies(process.version, requiredVersion)) {
|
|
127
|
+
logger.error('Minimum Node.js version not met :(');
|
|
128
|
+
logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
|
|
120
|
-
if (!semver.satisfies(process.version, requiredVersion)) {
|
|
121
|
-
logger.error('Minimum Node.js version not met :(');
|
|
122
|
-
logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
133
|
+
module.exports = beforeCli;
|
package/bin/docusaurus.js
CHANGED
|
@@ -23,7 +23,9 @@ const {
|
|
|
23
23
|
writeHeadingIds,
|
|
24
24
|
} = require('../lib');
|
|
25
25
|
|
|
26
|
-
require('./beforeCli');
|
|
26
|
+
const beforeCli = require('./beforeCli');
|
|
27
|
+
|
|
28
|
+
beforeCli();
|
|
27
29
|
|
|
28
30
|
const resolveDir = (dir = '.') => fs.realpathSync(dir);
|
|
29
31
|
|
|
@@ -208,7 +210,7 @@ cli
|
|
|
208
210
|
);
|
|
209
211
|
|
|
210
212
|
cli
|
|
211
|
-
.command('write-heading-ids [
|
|
213
|
+
.command('write-heading-ids [siteDir] [files...]')
|
|
212
214
|
.description('Generate heading ids in Markdown content.')
|
|
213
215
|
.option(
|
|
214
216
|
'--maintain-case',
|
|
@@ -239,7 +241,6 @@ function isInternalCommand(command) {
|
|
|
239
241
|
|
|
240
242
|
async function run() {
|
|
241
243
|
if (!isInternalCommand(process.argv.slice(2)[0])) {
|
|
242
|
-
// @ts-expect-error: Hmmm
|
|
243
244
|
await externalCommand(cli, resolveDir('.'));
|
|
244
245
|
}
|
|
245
246
|
|
|
@@ -38,11 +38,10 @@ function ComponentCreator(path, hash) {
|
|
|
38
38
|
Object.keys(flatChunkNames).forEach((key) => {
|
|
39
39
|
const chunkRegistry = registry[flatChunkNames[key]];
|
|
40
40
|
if (chunkRegistry) {
|
|
41
|
-
|
|
41
|
+
// eslint-disable-next-line prefer-destructuring
|
|
42
42
|
optsLoader[key] = chunkRegistry[0];
|
|
43
43
|
optsModules.push(chunkRegistry[1]);
|
|
44
44
|
optsWebpack.push(chunkRegistry[2]);
|
|
45
|
-
/* eslint-enable prefer-destructuring */
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
47
|
return Loadable.Map({
|
|
@@ -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 {
|
|
8
|
-
export default function externalCommand(cli:
|
|
7
|
+
import type { CommanderStatic } from 'commander';
|
|
8
|
+
export default function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
|
|
@@ -11,5 +11,5 @@ declare type Options = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function transformMarkdownHeadingLine(line: string, slugger: Slugger, options?: Options): string;
|
|
13
13
|
export declare function transformMarkdownContent(content: string, options?: Options): string;
|
|
14
|
-
export default function writeHeadingIds(siteDir: string, files?: string, options?: Options): Promise<void>;
|
|
14
|
+
export default function writeHeadingIds(siteDir: string, files?: string[], options?: Options): Promise<void>;
|
|
15
15
|
export {};
|
|
@@ -94,7 +94,7 @@ async function getPathsToWatch(siteDir) {
|
|
|
94
94
|
return plugins.flatMap((plugin) => { var _a, _b; return (_b = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.getPathsToWatch) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; });
|
|
95
95
|
}
|
|
96
96
|
async function writeHeadingIds(siteDir, files, options) {
|
|
97
|
-
const markdownFiles = await (0, utils_2.safeGlobby)(files ?
|
|
97
|
+
const markdownFiles = await (0, utils_2.safeGlobby)(files !== null && files !== void 0 ? files : (await getPathsToWatch(siteDir)), {
|
|
98
98
|
expandDirectories: ['**/*.{md,mdx}'],
|
|
99
99
|
});
|
|
100
100
|
const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));
|
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-
|
|
4
|
+
"version": "0.0.0-4518",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.16.3",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.16.3",
|
|
43
43
|
"@babel/traverse": "^7.16.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4518",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4518",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4518",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4518",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4518",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4518",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
|
|
52
52
|
"@svgr/webpack": "^6.0.0",
|
|
53
53
|
"autoprefixer": "^10.3.5",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"webpackbar": "^5.0.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
109
|
-
"@docusaurus/types": "0.0.0-
|
|
108
|
+
"@docusaurus/module-type-aliases": "0.0.0-4518",
|
|
109
|
+
"@docusaurus/types": "0.0.0-4518",
|
|
110
110
|
"@types/copy-webpack-plugin": "^8.0.1",
|
|
111
111
|
"@types/detect-port": "^1.3.0",
|
|
112
112
|
"@types/mini-css-extract-plugin": "^1.4.3",
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
"@types/react-router-config": "^5.0.1",
|
|
117
117
|
"@types/rtl-detect": "^1.0.0",
|
|
118
118
|
"@types/serve-handler": "^6.1.1",
|
|
119
|
+
"@types/update-notifier": "^5.1.0",
|
|
119
120
|
"@types/wait-on": "^5.2.0",
|
|
120
121
|
"@types/webpack-bundle-analyzer": "^4.4.1",
|
|
121
122
|
"react-test-renderer": "^17.0.2",
|
|
@@ -128,5 +129,5 @@
|
|
|
128
129
|
"engines": {
|
|
129
130
|
"node": ">=14"
|
|
130
131
|
},
|
|
131
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "734bca0f3ea8d04fa3b908d56ea0fb159ab47ab3"
|
|
132
133
|
}
|