@alauda/doom 0.7.3 → 0.8.0
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/load-config.js +6 -2
- package/lib/plugins/api/index.d.ts +1 -1
- package/lib/plugins/api/index.js +10 -15
- package/lib/plugins/api/types.d.ts +1 -0
- package/lib/plugins/replace/remark-replace.js +2 -4
- package/lib/plugins/replace/resolve-release.js +16 -6
- package/lib/plugins/replace/utils.d.ts +1 -0
- package/lib/plugins/replace/utils.js +2 -0
- package/package.json +1 -1
package/lib/cli/load-config.js
CHANGED
|
@@ -22,6 +22,7 @@ const zhLocaleConfig = {
|
|
|
22
22
|
const getCommonConfig = (config, cliRoot, configFilePath, version, force) => {
|
|
23
23
|
const fallbackToZh = 'lang' in config && config.lang == null;
|
|
24
24
|
const root = resolveDocRoot(CWD, cliRoot, config.root);
|
|
25
|
+
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
25
26
|
return {
|
|
26
27
|
root,
|
|
27
28
|
lang: fallbackToZh ? 'zh' : config.lang,
|
|
@@ -56,7 +57,10 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, force) => {
|
|
|
56
57
|
}),
|
|
57
58
|
},
|
|
58
59
|
plugins: [
|
|
59
|
-
apiPlugin(
|
|
60
|
+
apiPlugin({
|
|
61
|
+
...config.api,
|
|
62
|
+
localBasePath,
|
|
63
|
+
}),
|
|
60
64
|
autoSidebarPlugin(config.sidebar),
|
|
61
65
|
globalPlugin({
|
|
62
66
|
sites: config.sites,
|
|
@@ -65,7 +69,7 @@ const getCommonConfig = (config, cliRoot, configFilePath, version, force) => {
|
|
|
65
69
|
replacePlugin({
|
|
66
70
|
root,
|
|
67
71
|
lang: fallbackToZh ? null : (config.lang ?? 'en'),
|
|
68
|
-
localBasePath
|
|
72
|
+
localBasePath,
|
|
69
73
|
items: config.reference,
|
|
70
74
|
force,
|
|
71
75
|
releaseNotes: config.releaseNotes,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
2
|
import type { ApiPluginOptions } from './types.js';
|
|
3
|
-
export declare const apiPlugin: ({ crds, openapis, references, pathPrefix, }
|
|
3
|
+
export declare const apiPlugin: ({ localBasePath, crds, openapis, references, pathPrefix, }: ApiPluginOptions) => RspressPlugin;
|
package/lib/plugins/api/index.js
CHANGED
|
@@ -3,25 +3,24 @@ import { openapiSchemaToJsonSchema } from '@openapi-contrib/openapi-schema-to-js
|
|
|
3
3
|
import { convertObj } from 'swagger2openapi';
|
|
4
4
|
import { glob } from 'tinyglobby';
|
|
5
5
|
import { resolveStaticConfig } from '../../utils/index.js';
|
|
6
|
-
export const apiPlugin = ({ crds, openapis, references, pathPrefix, }
|
|
7
|
-
const crdsMap = {};
|
|
8
|
-
const openapisMap = {};
|
|
9
|
-
const shared = {};
|
|
6
|
+
export const apiPlugin = ({ localBasePath, crds, openapis, references, pathPrefix, }) => {
|
|
10
7
|
return {
|
|
11
8
|
name: 'doom-api',
|
|
12
|
-
async
|
|
9
|
+
async extendPageData(pageData) {
|
|
10
|
+
const crdsMap = {};
|
|
11
|
+
const openapisMap = {};
|
|
13
12
|
if (crds) {
|
|
14
13
|
for (const file of await glob(crds, {
|
|
15
|
-
cwd:
|
|
14
|
+
cwd: localBasePath,
|
|
16
15
|
})) {
|
|
17
|
-
crdsMap[file] = await resolveStaticConfig(path.resolve(
|
|
16
|
+
crdsMap[file] = await resolveStaticConfig(path.resolve(localBasePath, file));
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
if (openapis) {
|
|
21
20
|
for (const file of await glob(openapis, {
|
|
22
|
-
cwd:
|
|
21
|
+
cwd: localBasePath,
|
|
23
22
|
})) {
|
|
24
|
-
let doc = await resolveStaticConfig(path.resolve(
|
|
23
|
+
let doc = await resolveStaticConfig(path.resolve(localBasePath, file));
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
26
25
|
doc.info ??= { title: 'Unknown', version: '0.0.0' };
|
|
27
26
|
if ('swagger' in doc && doc.swagger === '2.0') {
|
|
@@ -34,14 +33,10 @@ export const apiPlugin = ({ crds, openapis, references, pathPrefix, } = {}) => {
|
|
|
34
33
|
openapisMap[file] = doc;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
shared.references = references;
|
|
38
|
-
shared.pathPrefix = pathPrefix;
|
|
39
|
-
},
|
|
40
|
-
extendPageData(pageData) {
|
|
41
36
|
pageData.crdsMap = crdsMap;
|
|
42
37
|
pageData.openapisMap = openapisMap;
|
|
43
|
-
pageData.references =
|
|
44
|
-
pageData.pathPrefix =
|
|
38
|
+
pageData.references = references;
|
|
39
|
+
pageData.pathPrefix = pathPrefix;
|
|
45
40
|
},
|
|
46
41
|
};
|
|
47
42
|
};
|
|
@@ -5,7 +5,7 @@ import { logger } from '@rspress/shared/logger';
|
|
|
5
5
|
import { parse, stringify } from 'yaml';
|
|
6
6
|
import { cyan, red } from 'yoctocolors';
|
|
7
7
|
import { normalizeImgSrc } from './normalize-img-src.js';
|
|
8
|
-
import { getFrontmatterNode, mdProcessor, mdxProcessor } from './utils.js';
|
|
8
|
+
import { getFrontmatterNode, isCI, mdProcessor, mdxProcessor } from './utils.js';
|
|
9
9
|
import { resolveReference } from './resolve-reference.js';
|
|
10
10
|
import { resolveRelease } from './resolve-release.js';
|
|
11
11
|
const MD_REF_START_COMMENT_PATTERN = /<!-{2,} *reference-start#(.+) *-{2,}>/;
|
|
@@ -24,8 +24,6 @@ export const maybeHaveRef = (filepath, content) => {
|
|
|
24
24
|
? [MDX_REF_START_COMMENT_PATTERN, MDX_RELEASE_COMMENT_PATTERN]
|
|
25
25
|
: [MD_REF_START_COMMENT_PATTERN, MD_RELEASE_COMMENT_PATTERN]).some((p) => p.test(content));
|
|
26
26
|
};
|
|
27
|
-
const { CI } = process.env;
|
|
28
|
-
const isCi = CI !== 'false' && !!CI;
|
|
29
27
|
export const remarkReplace = function ({ lang, localBasePath, root, items, force, releaseNotes }) {
|
|
30
28
|
return async (ast, vfile) => {
|
|
31
29
|
const filepath = vfile.path;
|
|
@@ -145,7 +143,7 @@ export const remarkReplace = function ({ lang, localBasePath, root, items, force
|
|
|
145
143
|
await fs.writeFile(filepath, newContent);
|
|
146
144
|
if (!vfile.data.original && isProduction()) {
|
|
147
145
|
const message = `Reference block in \`${cyan(relativePath)}\` has been updated, please commit the changes`;
|
|
148
|
-
if (
|
|
146
|
+
if (isCI) {
|
|
149
147
|
process.env.__DOOM_REBUILD__ = 'true';
|
|
150
148
|
}
|
|
151
149
|
logger.warn(message);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { logger } from '@rspress/shared/logger';
|
|
2
2
|
import { render } from 'ejs';
|
|
3
3
|
import { cyan, red } from 'yoctocolors';
|
|
4
|
+
import { isCI } from './utils.js';
|
|
4
5
|
const releaseCache = new Map();
|
|
5
6
|
const FIELD_MAPPER = {
|
|
6
7
|
zh: 'customfield_13800',
|
|
7
8
|
en: 'customfield_13801',
|
|
8
9
|
};
|
|
9
|
-
const {
|
|
10
|
+
const { JIRA_USERNAME, JIRA_PASSWORD } = process.env;
|
|
10
11
|
const issuesToMdast = (issues, lang) => {
|
|
11
12
|
return issues
|
|
12
13
|
.map((issue) => {
|
|
@@ -40,6 +41,7 @@ const issuesToMdast = (issues, lang) => {
|
|
|
40
41
|
})
|
|
41
42
|
.filter((_) => !!_);
|
|
42
43
|
};
|
|
44
|
+
let warned = false;
|
|
43
45
|
const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
44
46
|
const query = new URLSearchParams(releaseQuery);
|
|
45
47
|
const templateName = query.get('template');
|
|
@@ -53,14 +55,22 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
57
|
let Authorization;
|
|
56
|
-
if (
|
|
57
|
-
Authorization = `Bearer ${JIRA_TOKEN}`;
|
|
58
|
-
}
|
|
59
|
-
else if (JIRA_USERNAME && JIRA_PASSWORD) {
|
|
58
|
+
if (JIRA_USERNAME && JIRA_PASSWORD) {
|
|
60
59
|
Authorization = `Basic ${Buffer.from(`${JIRA_USERNAME}:${JIRA_PASSWORD}`).toString('base64')}`;
|
|
61
60
|
}
|
|
62
61
|
else {
|
|
63
|
-
|
|
62
|
+
if (warned) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
warned = true;
|
|
67
|
+
}
|
|
68
|
+
const message = `${cyan('`JIRA_USERNAME`')} and ${cyan('`JIRA_PASSWORD`')} environments must be set for fetching Jira issues`;
|
|
69
|
+
if (isCI) {
|
|
70
|
+
throw new Error(message);
|
|
71
|
+
}
|
|
72
|
+
logger.warn(message);
|
|
73
|
+
return;
|
|
64
74
|
}
|
|
65
75
|
const data = {};
|
|
66
76
|
for (const [key, value] of query.entries()) {
|
|
@@ -12,3 +12,4 @@ export declare const stringifySettings: Options;
|
|
|
12
12
|
export declare const mdProcessor: import("unified").FrozenProcessor<Root, Root, Root, string>;
|
|
13
13
|
export declare const mdxProcessor: import("unified").FrozenProcessor<Root, Root, Root, string>;
|
|
14
14
|
export declare const getFrontmatterNode: (ast: Root) => YAML | undefined;
|
|
15
|
+
export declare const isCI: boolean;
|