rspress 2.0.0-beta.11 → 2.0.0-beta.13
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/dist/index.js +25 -25
- package/package.json +5 -5
package/dist/index.js
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.
|
10
|
-
const findConfig = (basePath)=>
|
1
|
+
import external_node_path_default from "node:path";
|
2
|
+
import { build, dev, serve } from "@rspress/core";
|
3
|
+
import { logger } from "@rspress/shared/logger";
|
4
|
+
import { cac } from "cac";
|
5
|
+
import external_chokidar_default from "chokidar";
|
6
|
+
import external_picocolors_default from "picocolors";
|
7
|
+
import external_node_fs_default from "node:fs";
|
8
|
+
import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "@rspress/shared/constants";
|
9
|
+
var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.13"}');
|
10
|
+
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_default.existsSync);
|
11
11
|
async function loadConfigFile(customConfigFile) {
|
12
12
|
const baseDir = process.cwd();
|
13
13
|
let configFilePath = '';
|
14
|
-
configFilePath = customConfigFile ?
|
14
|
+
configFilePath = customConfigFile ? external_node_path_default.isAbsolute(customConfigFile) ? customConfigFile : external_node_path_default.join(baseDir, customConfigFile) : findConfig(external_node_path_default.join(baseDir, DEFAULT_CONFIG_NAME));
|
15
15
|
if (!configFilePath) {
|
16
|
-
|
16
|
+
logger.info(`No config file found in ${baseDir}`);
|
17
17
|
return {};
|
18
18
|
}
|
19
19
|
const { loadConfig } = await import("@rsbuild/core");
|
20
20
|
const { content } = await loadConfig({
|
21
|
-
cwd:
|
21
|
+
cwd: external_node_path_default.dirname(configFilePath),
|
22
22
|
path: configFilePath
|
23
23
|
});
|
24
24
|
return content;
|
25
25
|
}
|
26
26
|
function resolveDocRoot(cwd, cliRoot, configRoot) {
|
27
|
-
if (cliRoot) return
|
28
|
-
if (configRoot) return
|
29
|
-
return
|
27
|
+
if (cliRoot) return external_node_path_default.join(cwd, cliRoot);
|
28
|
+
if (configRoot) return external_node_path_default.isAbsolute(configRoot) ? configRoot : external_node_path_default.join(cwd, configRoot);
|
29
|
+
return external_node_path_default.join(cwd, 'docs');
|
30
30
|
}
|
31
31
|
const CONFIG_FILES = [
|
32
32
|
'rspress.config.ts',
|
33
33
|
'rspress.config.js'
|
34
34
|
];
|
35
35
|
const META_FILE = '_meta.json';
|
36
|
-
const cli =
|
36
|
+
const cli = cac('rspress').version(package_namespaceObject.i8).help();
|
37
37
|
const landingMessage = `\u{1F525} Rspress v${package_namespaceObject.i8}\n`;
|
38
|
-
|
38
|
+
logger.greet(landingMessage);
|
39
39
|
const setNodeEnv = (env)=>{
|
40
40
|
process.env.NODE_ENV = env;
|
41
41
|
};
|
@@ -51,7 +51,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
|
|
51
51
|
const config = await loadConfigFile(options?.config);
|
52
52
|
config.root = resolveDocRoot(cwd, root, config.root);
|
53
53
|
const docDirectory = config.root;
|
54
|
-
devServer = await
|
54
|
+
devServer = await dev({
|
55
55
|
appDirectory: cwd,
|
56
56
|
docDirectory,
|
57
57
|
config,
|
@@ -62,7 +62,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
|
|
62
62
|
}
|
63
63
|
}
|
64
64
|
});
|
65
|
-
cliWatcher =
|
65
|
+
cliWatcher = external_chokidar_default.watch([
|
66
66
|
`${cwd}/**/{${CONFIG_FILES.join(',')}}`,
|
67
67
|
docDirectory
|
68
68
|
], {
|
@@ -74,11 +74,11 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
|
|
74
74
|
]
|
75
75
|
});
|
76
76
|
cliWatcher.on('all', async (eventName, filepath)=>{
|
77
|
-
if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && (CONFIG_FILES.includes(
|
77
|
+
if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && (CONFIG_FILES.includes(external_node_path_default.basename(filepath)) || external_node_path_default.basename(filepath) === META_FILE)) {
|
78
78
|
if (isRestarting) return;
|
79
79
|
isRestarting = true;
|
80
80
|
console.log(`
|
81
|
-
\u{2728} ${eventName} ${
|
81
|
+
\u{2728} ${eventName} ${external_picocolors_default.green(external_node_path_default.relative(cwd, filepath))}, dev server will restart...\n`);
|
82
82
|
await devServer.close();
|
83
83
|
await cliWatcher.close();
|
84
84
|
await startDevServer();
|
@@ -105,12 +105,12 @@ cli.command('build [root]').action(async (root, options)=>{
|
|
105
105
|
config.root = resolveDocRoot(cwd, root, config.root);
|
106
106
|
const docDirectory = config.root;
|
107
107
|
try {
|
108
|
-
await
|
108
|
+
await build({
|
109
109
|
docDirectory,
|
110
110
|
config
|
111
111
|
});
|
112
112
|
} catch (err) {
|
113
|
-
|
113
|
+
logger.error(err);
|
114
114
|
process.exit(1);
|
115
115
|
}
|
116
116
|
});
|
@@ -120,7 +120,7 @@ cli.command('preview [root]').alias('serve').option('--port [port]', 'port numbe
|
|
120
120
|
const { port, host } = options || {};
|
121
121
|
const config = await loadConfigFile(options?.config);
|
122
122
|
config.root = resolveDocRoot(cwd, root, config.root);
|
123
|
-
await
|
123
|
+
await serve({
|
124
124
|
config,
|
125
125
|
host,
|
126
126
|
port
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "rspress",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.13",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
@@ -37,16 +37,16 @@
|
|
37
37
|
"meta-json-schema.json"
|
38
38
|
],
|
39
39
|
"dependencies": {
|
40
|
-
"@rsbuild/core": "~1.3.
|
40
|
+
"@rsbuild/core": "~1.3.22",
|
41
41
|
"cac": "^6.7.14",
|
42
42
|
"chokidar": "^3.6.0",
|
43
43
|
"picocolors": "^1.1.1",
|
44
|
-
"@rspress/core": "2.0.0-beta.
|
45
|
-
"@rspress/shared": "2.0.0-beta.
|
44
|
+
"@rspress/core": "2.0.0-beta.13",
|
45
|
+
"@rspress/shared": "2.0.0-beta.13"
|
46
46
|
},
|
47
47
|
"devDependencies": {
|
48
48
|
"@microsoft/api-extractor": "^7.52.8",
|
49
|
-
"@rslib/core": "0.
|
49
|
+
"@rslib/core": "0.9.2",
|
50
50
|
"@types/jest": "~29.5.14",
|
51
51
|
"@types/node": "^22.8.1",
|
52
52
|
"@types/react": "^19.1.6",
|