@alauda/doom 0.0.0-alpha.8 → 0.0.0-alpha.9

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="176" height="176" fill="none" fill-rule="evenodd" xmlns:v="https://vecta.io/nano"><path fill="#d8d8d8" opacity="0" d="M-8-12h200v200H-8z"/><g fill-rule="nonzero"><path d="M87.833 21.333c26.676 0 49.476 19.026 54.897 45.198l-5.879-2.798c-.977-.489-2.074-.733-3.173-.733a7.12 7.12 0 0 0-3.173.733L99.635 78.498c-2.014.976-3.477 2.746-3.966 4.941l-7.627 33.128c-.549 2.197 0 4.454 1.403 6.222l21.355 26.542c.609.768 1.345 1.386 2.162 1.84H40.539c-20.62-.063-37.871-15.908-39.99-36.729s11.578-39.912 31.75-44.252c3.967-28.039 27.63-48.857 55.534-48.857z" fill="#4da2f8"/><path d="M84.293 95.674l2.909 2.62 2.957 2.747 1.197 1.135-3.313 14.392c-.549 2.197 0 4.454 1.403 6.222l21.355 26.542c.609.768 1.345 1.386 2.162 1.84H40.539c-20.62-.063-37.871-15.908-39.99-36.729s11.578-39.912 31.75-44.252C45.8 68.435 63.132 76.93 84.293 95.674z" fill="#b3d7fc"/><path d="M175.166 115.81l-6.933-30.118c-.444-1.996-1.775-3.604-3.605-4.492l-28.065-13.367a6.47 6.47 0 0 0-2.884-.666 6.47 6.47 0 0 0-2.884.666l-28.065 13.423c-1.831.887-3.161 2.496-3.605 4.492l-6.933 30.117c-.499 1.997 0 4.049 1.275 5.657l19.413 24.129a6.54 6.54 0 0 0 5.158 2.495l31.28-.054c1.997 0 3.883-.943 5.158-2.496l19.415-24.127c1.275-1.608 1.719-3.661 1.275-5.657h0z" fill="#007af5"/><path d="M161.577 116.865c-.166 0-.278 0-.444-.057-.056-.054-.11-.054-.166-.054-.11 0-.222-.056-.332-.056-.388-.11-.666-.222-.999-.388-.166-.056-.332-.166-.499-.222h-.056c-1.055-.387-1.996-.721-2.884-.831h-.11c-.334 0-.5.166-.722.277-.054 0-.054.056-.11.056l-.666-.112a21.5 21.5 0 0 1-2.328 4.992c-1.887 2.996-4.382 5.436-7.322 7.156l.277.665c0 .056-.054.056-.054.11-.056.278-.166.502-.056.888.278.831.832 1.664 1.441 2.608v.054c.112.166.222.278.334.443.222.278.443.556.61.888.054.056.11.166.166.278 0 .056.054.056.054.11.222.444.222.943.11 1.387s-.443.777-.831.999a1.48 1.48 0 0 1-.665.166c-.666 0-1.331-.388-1.665-1.055 0 0-.054-.054-.054-.11-.056-.11-.112-.166-.166-.278-.168-.332-.222-.665-.334-.997l-.166-.5v-.054c-.388-1.055-.721-1.997-1.165-2.774-.222-.332-.443-.444-.721-.499-.056-.056-.056-.056-.11-.056l-.334-.609a24.66 24.66 0 0 1-2.884.831c-1.552.388-3.217.555-4.824.555a21.67 21.67 0 0 1-7.766-1.443l-.388.722c-.054.054-.054.054-.11.054-.222.112-.499.168-.721.5-.5.777-.778 1.663-1.165 2.773l-.166.5c-.112.332-.166.61-.334.997-.068.085-.123.178-.166.278 0 0-.054.056-.054.11-.332.61-.999 1.055-1.665 1.055-.221 0-.443-.056-.665-.166-.832-.388-1.165-1.443-.721-2.386 0 0 .054-.054.054-.11.056-.112.112-.222.166-.277.223-.334.388-.612.61-.888.112-.166.222-.278.332-.444v-.054c.612-.944 1.11-1.775 1.443-2.606.11-.39 0-.666-.112-.888 0-.054-.054-.054-.054-.112l.332-.721a22.46 22.46 0 0 1-2.386-1.608c-3.397-2.683-5.925-6.311-7.264-10.428l-.777.112c-.056 0-.056-.056-.112-.056-.166-.112-.388-.276-.721-.276h-.11c-.888.11-1.831.443-2.884.831h-.056c-.166.056-.332.166-.499.222-.334.166-.612.276-.999.388-.112 0-.222.054-.332.054 0 .056-.056.056-.112.056-.166.056-.277.056-.444.056-.885 0-1.608-.499-1.774-1.275-.166-.888.443-1.831 1.441-2.053.056-.054.112-.054.166-.054.112 0 .222-.056.334-.056.388-.054.721-.112 1.053-.112.168-.054.388-.054.555-.054h.056c1.165-.112 2.164-.222 2.995-.5a1.29 1.29 0 0 0 .61-.609c0-.056.056-.056.056-.112l.721-.221c-.721-5.104.332-10.262 3.106-14.644.054-.166.166-.278.277-.444l-.555-.499v-.112c0-.277 0-.555-.276-.831-.666-.61-1.499-1.109-2.496-1.719-.168-.112-.334-.222-.5-.278-.332-.166-.61-.332-.943-.555-.11-.056-.166-.165-.277-.222-.056 0-.056-.054-.112-.054-.777-.666-.943-1.775-.387-2.496.277-.388.775-.61 1.275-.61a1.94 1.94 0 0 1 1.219.444c0 .054.054.054.112.11.11.11.221.166.276.222.278.277.5.499.722.777.165.11.277.277.387.388.777.831 1.497 1.553 2.219 2.052.146.104.32.162.499.166.112 0 .222-.054.332-.054h.112l.555.387a21.38 21.38 0 0 1 10.983-6.211c.997-.222 1.996-.332 2.995-.444l.054-.721.112-.11c.166-.168.387-.334.444-.722.11-.887-.056-1.886-.168-2.995v-.056c-.054-.222-.054-.388-.11-.555-.11-.332-.166-.666-.166-1.053v-.444c-.013-.475.167-.935.499-1.275.332-.334.777-.555 1.221-.555.943 0 1.719.831 1.719 1.83v.499l-.166 1.055c-.056.168-.112.388-.112.555v.056c-.11 1.109-.222 2.106-.166 2.995.056.388.278.555.444.721l.11.112.056.721a22.15 22.15 0 0 1 11.592 4.604c.777.665 1.553 1.331 2.274 2.108l.666-.444h.11c.112.056.222.056.334.056.179-.004.353-.062.499-.166.721-.5 1.441-1.166 2.219-1.997.165-.11.277-.277.387-.388a9.38 9.38 0 0 1 .722-.777c.11-.054.166-.165.276-.222l.112-.11c.388-.278.775-.444 1.219-.444.5 0 .999.223 1.275.61.556.721.388 1.831-.388 2.496 0 .056-.054.056-.11.11-.11.112-.222.168-.276.222-.334.222-.61.388-.944.555-.166.112-.332.168-.499.278-.999.61-1.83 1.109-2.496 1.719-.222.278-.277.555-.277.832v.11l-.556.5c1.45 2.223 2.502 4.681 3.108 7.264.609 2.608.719 5.27.387 7.82l.721.222c0 .056.056.056.056.112.112.222.222.443.61.61.888.277 1.83.387 2.995.497h.056c.222.057.388.057.555.057.332 0 .666.054 1.055.11.11 0 .221.056.332.056 0 .054.056.054.11.054h.056c.999.278 1.609 1.165 1.609 1.831-.222.721-.944 1.277-1.775 1.277h0z" fill="#fff"/><path d="M136.563 101.5c.468.59 1.304.733 1.942.332l7.264-5.158h.001a16.84 16.84 0 0 0-9.984-4.826l.499 9.041c.056.222.112.443.278.61h0zm-11.036 6.434c.499-.61.443-1.553-.168-2.052l-6.6-5.88c-1.997 3.273-2.828 7.1-2.496 10.872l8.597-2.496a1.1 1.1 0 0 0 .666-.444h0zm3.937-5.825c.832 0 1.441-.665 1.497-1.441l.499-8.875-1.774.334h-.001a16.92 16.92 0 0 0-8.265 4.548l7.378 5.269c.168.112.444.166.666.166h0zm1.718 8.931l2.44 1.165 2.44-1.165.555-2.608-1.664-2.106h-2.718l-1.664 2.106zm9.097 2.608c-.634.316-.959 1.035-.777 1.719l3.493 8.373c2.108-1.387 3.937-3.161 5.324-5.379h.001c.721-1.053 1.277-2.162 1.609-3.383l-8.875-1.497c-.277 0-.555.056-.777.166zm10.259-8.376a17.77 17.77 0 0 0-2.106-5.27l-6.711 6.047a1.32 1.32 0 0 0-.334.61c-.173.777.289 1.555 1.055 1.774l8.485 2.442a17.43 17.43 0 0 0-.387-5.602h-.001 0zm-24.457 8.264l-8.819 1.496v.001a17.48 17.48 0 0 0 6.932 8.707l3.384-8.153c.112-.278.112-.555.054-.887-.166-.721-.831-1.222-1.552-1.165h0zm8.096 3.772c-.61-.332-1.33-.112-1.774.388l-4.383 7.931c1.777.555 3.661.888 5.602.888 1.333 0 2.608-.166 3.883-.444l1.608-.444-4.27-7.709a2.33 2.33 0 0 0-.666-.61h0z" fill="#007af5"/></g></svg>
@@ -3,3 +3,5 @@ export declare const YAML_EXTENSIONS: readonly [".yaml", ".yml"];
3
3
  export declare const JS_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
4
4
  export declare const DEFAULT_EXTENSIONS: readonly [".yaml", ".yml", ".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
5
5
  export declare const DEFAULT_CONFIGS: ("doom.config.yaml" | "doom.config.yml" | "doom.config.js" | "doom.config.ts" | "doom.config.mjs" | "doom.config.mts" | "doom.config.cjs" | "doom.config.cts")[];
6
+ export declare const I18N_FILE = "i18n.json";
7
+ export declare const CWD: string;
@@ -13,3 +13,5 @@ export const DEFAULT_EXTENSIONS = [
13
13
  ...JS_EXTENSIONS,
14
14
  ];
15
15
  export const DEFAULT_CONFIGS = DEFAULT_EXTENSIONS.map((ext) => `${DEFAULT_CONFIG_NAME}${ext}`);
16
+ export const I18N_FILE = 'i18n.json';
17
+ export const CWD = process.cwd();
package/lib/cli/index.js CHANGED
@@ -9,12 +9,10 @@ import { watch } from 'chokidar';
9
9
  import { program } from 'commander';
10
10
  import { green } from 'yoctocolors';
11
11
  import module from 'node:module';
12
- import { DEFAULT_CONFIGS } from './constants.js';
13
- import { loadConfig, resolveDocRoot } from './load-config.js';
14
- const I18N_FILE = 'i18n.json';
12
+ import { CWD, DEFAULT_CONFIGS, I18N_FILE } from './constants.js';
13
+ import { loadConfig } from './load-config.js';
15
14
  const META_FILE = '_meta.json';
16
15
  const CONFIG_FILES = [...DEFAULT_CONFIGS, I18N_FILE];
17
- const cwd = process.cwd();
18
16
  const setNodeEnv = (env) => {
19
17
  process.env.NODE_ENV = env;
20
18
  };
@@ -36,13 +34,11 @@ program
36
34
  let cliWatcher;
37
35
  const startDevServer = async () => {
38
36
  const { config, filepath } = await loadConfig(root, configFile);
39
- config.root = resolveDocRoot(cwd, root, config.root);
40
- config.i18nSourcePath = path.resolve(config.root, I18N_FILE);
41
37
  const docDirectory = config.root;
42
38
  try {
43
39
  devServer = await dev({
44
40
  config,
45
- appDirectory: cwd,
41
+ appDirectory: CWD,
46
42
  docDirectory,
47
43
  extraBuilderConfig: {
48
44
  server,
@@ -53,23 +49,26 @@ program
53
49
  logger.error(err);
54
50
  devServer = undefined;
55
51
  }
56
- cliWatcher = watch(filepath ? [filepath, docDirectory] : [...CONFIG_FILES, docDirectory], {
52
+ cliWatcher = watch(filepath
53
+ ? [filepath, docDirectory, config.i18nSourcePath]
54
+ : [...CONFIG_FILES, docDirectory], {
57
55
  ignoreInitial: true,
58
56
  ignored: ['**/node_modules/**', '**/.git/**', '**/.DS_Store/**'],
59
- cwd,
57
+ cwd: CWD,
60
58
  });
61
59
  let isRestarting = false;
62
60
  cliWatcher.on('all', async (eventName, filepath) => {
63
61
  if (eventName === 'add' ||
64
62
  eventName === 'unlink' ||
65
63
  (eventName === 'change' &&
66
- (CONFIG_FILES.includes(path.basename(filepath)) ||
64
+ (filepath === config.i18nSourcePath ||
65
+ CONFIG_FILES.includes(path.basename(filepath)) ||
67
66
  path.basename(filepath) === META_FILE))) {
68
67
  if (isRestarting) {
69
68
  return;
70
69
  }
71
70
  isRestarting = true;
72
- console.log(`\n✨ ${eventName} ${green(path.relative(cwd, filepath))}, dev server will restart...\n`);
71
+ console.log(`\n✨ ${eventName} ${green(path.relative(CWD, filepath))}, dev server will restart...\n`);
73
72
  await devServer?.close();
74
73
  await cliWatcher.close();
75
74
  await startDevServer();
@@ -95,12 +94,10 @@ program
95
94
  .action(async (root, { config: configFile }) => {
96
95
  setNodeEnv('production');
97
96
  const { config } = await loadConfig(root, configFile);
98
- config.root = resolveDocRoot(cwd, root, config.root);
99
- config.i18nSourcePath = path.resolve(config.root, I18N_FILE);
100
97
  const docDirectory = config.root;
101
98
  await build({
102
99
  config,
103
- appDirectory: cwd,
100
+ appDirectory: CWD,
104
101
  docDirectory,
105
102
  });
106
103
  })
@@ -113,8 +110,6 @@ program
113
110
  .action(async (root, { config: configFile, ...server }) => {
114
111
  setNodeEnv('production');
115
112
  const { config } = await loadConfig(root, configFile);
116
- config.root = resolveDocRoot(cwd, root, config.root);
117
- config.i18nSourcePath = path.resolve(config.root, I18N_FILE);
118
113
  await serve({
119
114
  config,
120
115
  ...server,
@@ -6,11 +6,13 @@ import path from 'node:path';
6
6
  import rehypeRaw from 'rehype-raw';
7
7
  import { parse } from 'yaml';
8
8
  import { autoSidebarPlugin, globalPlugin } from '../plugins/index.js';
9
- import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, YAML_EXTENSIONS, } from './constants.js';
9
+ import { pkgResolve } from '../utils/helpers.js';
10
+ import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, YAML_EXTENSIONS, } from './constants.js';
11
+ const DEFAULT_LOGO = path.relative(CWD, pkgResolve('assets/logo.svg'));
10
12
  const COMMON_CONFIG = {
11
13
  lang: 'en',
12
- logo: '/logo.svg',
13
- icon: '/logo.svg',
14
+ logo: DEFAULT_LOGO,
15
+ icon: DEFAULT_LOGO,
14
16
  markdown: {
15
17
  checkDeadLinks: true,
16
18
  mdxRs: false,
@@ -88,6 +90,15 @@ export async function loadConfig(root, configFile) {
88
90
  const mergedConfig = mergeRsbuildConfig(COMMON_CONFIG, config ?? {});
89
91
  const base = addLeadingSlash(mergedConfig.base || '/');
90
92
  mergedConfig.base = base;
93
+ mergedConfig.root = resolveDocRoot(CWD, root, mergedConfig.root);
94
+ if (mergedConfig.i18nSourcePath) {
95
+ if (!path.isAbsolute(mergedConfig.i18nSourcePath)) {
96
+ mergedConfig.i18nSourcePath = path.resolve(configFilePath, mergedConfig.i18nSourcePath);
97
+ }
98
+ }
99
+ else {
100
+ mergedConfig.i18nSourcePath = path.resolve(mergedConfig.root, I18N_FILE);
101
+ }
91
102
  if (!mergedConfig.outDir) {
92
103
  mergedConfig.outDir = `dist${base}`;
93
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.0.0-alpha.8",
3
+ "version": "0.0.0-alpha.9",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "https://gitlab-ce.alauda.cn/idp/Doom",
@@ -14,6 +14,7 @@
14
14
  "./runtime": "./lib/runtime/index.js"
15
15
  },
16
16
  "files": [
17
+ "assets",
17
18
  "global.d.ts",
18
19
  "lib",
19
20
  "styles",