@alauda/doom 0.17.6 → 0.18.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.
package/lib/cli/export.js CHANGED
@@ -8,7 +8,7 @@ import { pathExists, setNodeEnv } from '../utils/index.js';
8
8
  import { generatePdf, } from './export-pdf-core/index.js';
9
9
  import { loadConfig } from './load-config.js';
10
10
  export const exportCommand = new Command('export')
11
- .description('Export the documentation as PDF')
11
+ .description('Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically')
12
12
  .argument('[root]', 'Root directory of the documentation')
13
13
  .option('-H, --host [host]', 'Serve host name')
14
14
  .option('-P, --port [port]', 'Serve port number', '4173')
@@ -22,10 +22,12 @@ export const exportCommand = new Command('export')
22
22
  process.exit(1);
23
23
  }
24
24
  config = await autoSidebar(config, {
25
- excludeRoutes: (globalOptions.ignore && config.internalRoutes) || [],
25
+ ignore: globalOptions.ignore,
26
+ export: true,
26
27
  });
27
28
  config.builderConfig.server.open = false;
28
- const themeConfig = config.themeConfig;
29
+ // make sure it won't be overridden by `serve`
30
+ const themeConfig = { ...config.themeConfig };
29
31
  logger.start('Serving...');
30
32
  await serve({ config, host, port });
31
33
  const collectPages = (sidebarItems) => {
@@ -80,6 +82,7 @@ export const exportCommand = new Command('export')
80
82
  },
81
83
  };
82
84
  const exportPdf = async (sidebarItems, lang = config.lang) => {
85
+ // console.log(sidebarItems, collectPages(sidebarItems))
83
86
  await generatePdf({
84
87
  pages: collectPages(sidebarItems),
85
88
  outFile: getPdfName(lang, config.userBase, config.title),
@@ -23,7 +23,6 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
23
23
  const fallbackToZh = 'lang' in config && !config.lang;
24
24
  root = resolveDocRoot(CWD, root, config.root);
25
25
  const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
26
- const excludeRoutes = (ignore && config.internalRoutes) || [];
27
26
  const userBase = (base = addLeadingSlash(addTrailingSlash(base || config.base || '/')));
28
27
  if (version && version !== 'unversioned') {
29
28
  base = userBase + `${version}/`;
@@ -42,7 +41,6 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
42
41
  'doom.config.*',
43
42
  '**/assets/**/*',
44
43
  '**/*.d.ts',
45
- ...excludeRoutes,
46
44
  ],
47
45
  },
48
46
  markdown: {
@@ -71,9 +69,7 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
71
69
  apiPlugin({
72
70
  localBasePath,
73
71
  }),
74
- autoSidebarPlugin({
75
- excludeRoutes,
76
- }),
72
+ autoSidebarPlugin({ ignore }),
77
73
  directivesPlugin(),
78
74
  globalPlugin({ version, download }),
79
75
  mermaidPlugin(),
package/lib/cli/new.js CHANGED
@@ -6,6 +6,7 @@ import { Command } from 'commander';
6
6
  import { render } from 'ejs';
7
7
  import { glob } from 'tinyglobby';
8
8
  import { cyan, magenta } from 'yoctocolors';
9
+ import { JS_STR_FALSY_VALUES } from '../shared/index.js';
9
10
  import { resolveRepo, resolveStaticConfig } from '../utils/index.js';
10
11
  export const DEFAULT_PATH = 'templates/scaffolding.yaml';
11
12
  const scaffoldingTemplates = {
@@ -97,14 +98,16 @@ export const newCommand = new Command('new')
97
98
  }
98
99
  const parameters = {};
99
100
  for (const param of scaffolding.parameters || []) {
100
- parameters[param.name] = await prompts[param.type](param.options);
101
+ parameters[param.name] =
102
+ await // @ts-expect-error -- no idea how to fix this
103
+ prompts[param.type](param.options);
101
104
  }
102
105
  logger.start('Generating scaffolding...');
103
106
  for (const layout of scaffolding.layout || []) {
104
107
  const source = path.resolve(base, render(layout.source, { parameters }));
105
108
  const target = path.resolve(render(layout.target, { parameters }));
106
109
  const when = layout.when && render(layout.when, { parameters });
107
- if (['', '0', 'false', 'null', 'undefined'].includes(when)) {
110
+ if (JS_STR_FALSY_VALUES.has(when)) {
108
111
  continue;
109
112
  }
110
113
  switch (layout.type) {
@@ -2,8 +2,9 @@ import { type RspressPlugin, type UserConfig } from '@rspress/core';
2
2
  export type * from './walk.js';
3
3
  export type * from './type.js';
4
4
  export interface AutoSidebarPluginOptions {
5
- excludeRoutes?: string[];
5
+ ignore?: boolean;
6
+ export?: boolean;
6
7
  collapsed?: boolean;
7
8
  }
8
- export declare const autoSidebar: (config: UserConfig, { excludeRoutes }: AutoSidebarPluginOptions) => Promise<UserConfig<import("@rspress/shared").DefaultThemeConfig>>;
9
+ export declare const autoSidebar: (config: UserConfig, { ignore, export: export_ }: AutoSidebarPluginOptions) => Promise<UserConfig<import("@rspress/shared").DefaultThemeConfig>>;
9
10
  export declare const autoSidebarPlugin: (options?: AutoSidebarPluginOptions) => RspressPlugin;
@@ -154,17 +154,26 @@ function processLocales(langs, versions, root, defaultLang, defaultVersion, exte
154
154
  }));
155
155
  }
156
156
  const defaultExtensions = ['.mdx', '.md', '.tsx', '.jsx', '.ts', '.js'];
157
- export const autoSidebar = async (config, { excludeRoutes }) => {
158
- config.themeConfig = config.themeConfig || {};
159
- config.themeConfig.locales =
160
- config.themeConfig.locales || config.locales || [];
157
+ const APIS_ROUTES = ['apis/**', '*/apis/**'];
158
+ export const autoSidebar = async (config, { ignore, export: export_ }) => {
159
+ const excludeRoutes = (ignore && config.internalRoutes) || [];
160
+ const route = (config.route ??= {});
161
+ if (export_ || excludeRoutes.length) {
162
+ if (export_) {
163
+ excludeRoutes.push(...APIS_ROUTES);
164
+ }
165
+ const exclude = (route.exclude ??= []);
166
+ exclude.push(...excludeRoutes);
167
+ }
168
+ config.themeConfig ??= {};
169
+ config.themeConfig.locales ??= config.locales || [];
161
170
  const root = config.root;
162
171
  const langs = config.themeConfig.locales.map((locale) => locale.lang);
163
172
  const hasLocales = langs.length > 0;
164
173
  const versions = config.multiVersion?.versions || [];
165
174
  const defaultLang = config.lang || '';
166
175
  const { default: defaultVersion = '' } = config.multiVersion || {};
167
- const { extensions = defaultExtensions } = config.route || {};
176
+ const { extensions = defaultExtensions } = route;
168
177
  const collapsed = config.sidebar?.collapsed;
169
178
  if (hasLocales) {
170
179
  const metaInfo = await processLocales(langs, versions, root, defaultLang, defaultVersion, extensions, excludeRoutes, collapsed);
@@ -1,2 +1,3 @@
1
1
  export declare const ACP_BASE = "/container_platform/";
2
2
  export declare const FALSY_VALUES: Set<string>;
3
+ export declare const JS_STR_FALSY_VALUES: Set<string>;
@@ -1,2 +1,9 @@
1
1
  export const ACP_BASE = '/container_platform/';
2
- export const FALSY_VALUES = new Set(['0', 'false', 'no', 'off', 'n', 'f']);
2
+ export const FALSY_VALUES = new Set(['', '0', 'false', 'no', 'off', 'n', 'f']);
3
+ export const JS_STR_FALSY_VALUES = new Set([
4
+ '',
5
+ '0',
6
+ 'false',
7
+ 'null',
8
+ 'undefined',
9
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.17.6",
3
+ "version": "0.18.9",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
@@ -30,6 +30,7 @@
30
30
  "doom": "yarn swc-node src/cli/index.ts",
31
31
  "export": "yarn doom export",
32
32
  "fixture": "yarn dev fixture-docs",
33
+ "format": "prettier --write .",
33
34
  "lint": "run-p 'lint:*'",
34
35
  "lint:es": "eslint . --cache",
35
36
  "lint:tsc": "tsc -b",
@@ -40,7 +41,7 @@
40
41
  "translate": "yarn doom translate fixture-docs"
41
42
  },
42
43
  "dependencies": {
43
- "@inquirer/prompts": "^7.4.0",
44
+ "@inquirer/prompts": "^7.4.1",
44
45
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
45
46
  "@playwright/browser-chromium": "^1.51.1",
46
47
  "@rsbuild/plugin-yaml": "^1.0.2",
@@ -70,14 +71,14 @@
70
71
  "simple-git": "^3.27.0",
71
72
  "swagger2openapi": "^7.0.8",
72
73
  "tinyglobby": "^0.2.12",
73
- "type-fest": "^4.39.0",
74
+ "type-fest": "^4.39.1",
74
75
  "yaml": "^2.7.1",
75
76
  "yoctocolors": "^2.1.1"
76
77
  },
77
78
  "devDependencies": {
78
- "@eslint/js": "^9.23.0",
79
+ "@eslint/js": "^9.24.0",
79
80
  "@swc-node/register": "^1.10.10",
80
- "@swc/core": "1.11.16",
81
+ "@swc/core": "1.11.18",
81
82
  "@types/cli-progress": "^3.11.6",
82
83
  "@types/ejs": "^3.1.5",
83
84
  "@types/node": "^18.19.86",
@@ -86,16 +87,16 @@
86
87
  "@types/react-dom": "^18.3.6",
87
88
  "@types/swagger2openapi": "^7.0.4",
88
89
  "@unts/patch-package": "^8.1.1",
89
- "eslint": "^9.23.0",
90
- "eslint-import-resolver-typescript": "^4.3.1",
91
- "eslint-plugin-import-x": "^4.10.0",
90
+ "eslint": "^9.24.0",
91
+ "eslint-import-resolver-typescript": "^4.3.2",
92
+ "eslint-plugin-import-x": "^4.10.2",
92
93
  "lint-staged": "^15.5.0",
93
94
  "npm-run-all2": "^7.0.2",
94
95
  "prettier": "^3.5.3",
95
- "prettier-plugin-pkg": "^0.18.1",
96
+ "prettier-plugin-pkg": "^0.19.0",
96
97
  "simple-git-hooks": "^2.12.1",
97
- "typescript": "^5.8.2",
98
- "typescript-eslint": "^8.29.0",
98
+ "typescript": "^5.8.3",
99
+ "typescript-eslint": "^8.29.1",
99
100
  "yarn-berry-deduplicate": "^6.1.1"
100
101
  },
101
102
  "publishConfig": {