@alauda/doom 0.5.3 → 0.5.4
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/index.js +7 -6
- package/lib/cli/load-config.d.ts +1 -1
- package/lib/cli/load-config.js +6 -3
- package/package.json +1 -1
package/lib/cli/index.js
CHANGED
|
@@ -27,6 +27,7 @@ program
|
|
|
27
27
|
})
|
|
28
28
|
.option('-c, --config [config]', 'Specify the path to the config file')
|
|
29
29
|
.option('-v <version>', 'Specify the version of the documentation')
|
|
30
|
+
.option('-p, --prefix <prefix>', 'Specify the prefix of the documentation base')
|
|
30
31
|
.command('dev', { isDefault: true })
|
|
31
32
|
.description('Start the development server')
|
|
32
33
|
.argument('[root]', 'Root directory of the documentation')
|
|
@@ -36,9 +37,9 @@ program
|
|
|
36
37
|
setNodeEnv('development');
|
|
37
38
|
let devServer;
|
|
38
39
|
let cliWatcher;
|
|
39
|
-
const { config: configFile, v: version, ...server } = this.optsWithGlobals();
|
|
40
|
+
const { config: configFile, v: version, prefix, ...server } = this.optsWithGlobals();
|
|
40
41
|
const startDevServer = async () => {
|
|
41
|
-
const { config, filepath } = await loadConfig(root, configFile, version);
|
|
42
|
+
const { config, filepath } = await loadConfig(root, configFile, prefix, version);
|
|
42
43
|
const docDirectory = config.root;
|
|
43
44
|
try {
|
|
44
45
|
devServer = await dev({
|
|
@@ -101,8 +102,8 @@ program
|
|
|
101
102
|
.argument('[root]', 'Root directory of the documentation')
|
|
102
103
|
.action(async function (root) {
|
|
103
104
|
setNodeEnv('production');
|
|
104
|
-
const { config: configFile, v: version } = this.optsWithGlobals();
|
|
105
|
-
const { config } = await loadConfig(root, configFile, version);
|
|
105
|
+
const { config: configFile, prefix, v: version, } = this.optsWithGlobals();
|
|
106
|
+
const { config } = await loadConfig(root, configFile, prefix, version);
|
|
106
107
|
const docDirectory = config.root;
|
|
107
108
|
await build({
|
|
108
109
|
config,
|
|
@@ -119,8 +120,8 @@ program
|
|
|
119
120
|
.option('--host [host]', 'Host name')
|
|
120
121
|
.action(async function (root) {
|
|
121
122
|
setNodeEnv('production');
|
|
122
|
-
const { config: configFile, v: version, ...server } = this.optsWithGlobals();
|
|
123
|
-
const { config } = await loadConfig(root, configFile, version);
|
|
123
|
+
const { config: configFile, prefix, v: version, ...server } = this.optsWithGlobals();
|
|
124
|
+
const { config } = await loadConfig(root, configFile, prefix, version);
|
|
124
125
|
await serve({
|
|
125
126
|
config,
|
|
126
127
|
...server,
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DoomConfig } from '../utils/index.js';
|
|
2
|
-
export declare function loadConfig(root?: string, configFile?: string, version?: string): Promise<{
|
|
2
|
+
export declare function loadConfig(root?: string, configFile?: string, prefix?: string, version?: string): Promise<{
|
|
3
3
|
config: DoomConfig;
|
|
4
4
|
filepath?: string;
|
|
5
5
|
}>;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { nodeTypes } from '@mdx-js/mdx';
|
|
4
|
-
import { addLeadingSlash, addTrailingSlash, removeLeadingSlash, removeTrailingSlash, } from '@rspress/core';
|
|
4
|
+
import { addLeadingSlash, addTrailingSlash, normalizeSlash, removeLeadingSlash, removeTrailingSlash, } from '@rspress/core';
|
|
5
5
|
import { pluginPreview } from '@rspress/plugin-preview';
|
|
6
6
|
import { logger } from '@rspress/shared/logger';
|
|
7
7
|
import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
|
|
@@ -100,7 +100,7 @@ const getCommonConfig = async (config, version) => {
|
|
|
100
100
|
const findConfig = (basePath) => {
|
|
101
101
|
return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
|
|
102
102
|
};
|
|
103
|
-
export async function loadConfig(root, configFile, version) {
|
|
103
|
+
export async function loadConfig(root, configFile, prefix, version) {
|
|
104
104
|
let configFilePath;
|
|
105
105
|
if (configFile) {
|
|
106
106
|
configFilePath = path.resolve(configFile);
|
|
@@ -156,6 +156,9 @@ export async function loadConfig(root, configFile, version) {
|
|
|
156
156
|
base = removeTrailingSlash(base) + `/${normalizedVersion}`;
|
|
157
157
|
}
|
|
158
158
|
mergedConfig.base = base = addTrailingSlash(base);
|
|
159
|
+
if (prefix) {
|
|
160
|
+
mergedConfig.base = normalizeSlash(prefix) + base;
|
|
161
|
+
}
|
|
159
162
|
mergedConfig.root = resolveDocRoot(CWD, root, mergedConfig.root);
|
|
160
163
|
let ensureDefaultLogo = false;
|
|
161
164
|
if (!mergedConfig.logo) {
|
|
@@ -190,7 +193,7 @@ export async function loadConfig(root, configFile, version) {
|
|
|
190
193
|
mergedConfig.outDir = `dist${normalizedVersion === 'unversioned' ? `/unversioned${base}` : base}`;
|
|
191
194
|
}
|
|
192
195
|
if (mergedConfig.builderConfig?.server?.open === true) {
|
|
193
|
-
mergedConfig.builderConfig.server.open = base;
|
|
196
|
+
mergedConfig.builderConfig.server.open = mergedConfig.base;
|
|
194
197
|
}
|
|
195
198
|
return {
|
|
196
199
|
config: mergedConfig,
|