Skip to content

Commit 9922ca3

Browse files
committed
fix: fix the plugins in resovledConfig
1 parent e4016d3 commit 9922ca3

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,10 @@ exports[`resolveConfig > should resolve extends with local file config which con
534534
"overlay1Rules": {
535535
"info-contact": "off",
536536
},
537+
"plugins": [
538+
"api/plugin.js",
539+
"plugin.js",
540+
],
537541
"preprocessors": {},
538542
"rules": {
539543
"boolean-parameter-prefixes": "error",

packages/core/src/config/__tests__/__snapshots__/load.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Config {
7777
},
7878
},
7979
},
80-
"plugins": undefined,
80+
"plugins": [],
8181
"resolve": {
8282
"http": {
8383
"headers": [],

packages/core/src/config/__tests__/config-resolvers.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ describe('resolveApis', () => {
500500
configPath
501501
),
502502
});
503-
const { resolvedConfig: mergedGovernancePresetResolved } = mergedGovernancePreset;
503+
const {
504+
resolvedConfig: { plugins, ...mergedGovernancePresetResolved },
505+
} = mergedGovernancePreset;
504506
const rawConfig: RawUniversalConfig = {
505507
apis: {
506508
petstore: {

packages/core/src/config/__tests__/load.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('loadConfig', () => {
8383
`);
8484
expect(config.resolvedConfig).toMatchInlineSnapshot(`
8585
{
86-
"plugins": undefined,
86+
"plugins": [],
8787
"rules": {
8888
"info-license": "error",
8989
"non-existing-rule": "warn",
@@ -941,6 +941,7 @@ describe('loadConfig', () => {
941941
configPath: path.join(__dirname, './fixtures/resolve-refs-in-config/config-with-refs.yaml'),
942942
});
943943
expect(resolvedConfig).toEqual({
944+
plugins: [],
944945
seo: {
945946
title: 1,
946947
},

packages/core/src/config/config-resolvers.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ export async function resolveConfig({
8181
});
8282

8383
let resolvedPlugins: Plugin[];
84+
let rootConfigDir: string = '';
8485
if (isBrowser) {
8586
// In browser, we don't support plugins from config file yet
8687
resolvedPlugins = [defaultPlugin];
8788
} else {
88-
const rootConfigDir = path.dirname(configPath ?? '');
89+
rootConfigDir = path.dirname(configPath ?? '');
8990
const pluginsOrPaths = collectConfigPlugins(rootDocument, resolvedRefMap, rootConfigDir);
9091
const plugins = await resolvePlugins(pluginsOrPaths, rootConfigDir);
9192
resolvedPlugins = [...plugins, defaultPlugin];
@@ -107,7 +108,12 @@ export async function resolveConfig({
107108
}
108109

109110
return {
110-
resolvedConfig: bundledConfig,
111+
resolvedConfig: {
112+
...bundledConfig,
113+
plugins: resolvedPlugins
114+
.map((p) => (p.absolutePath ? path.relative(rootConfigDir, p.absolutePath) : undefined))
115+
.filter(isDefined),
116+
},
111117
resolvedRefMap,
112118
plugins: resolvedPlugins,
113119
};

packages/core/src/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ export type RawUniversalConfig = Omit<Partial<RedoclyConfig>, 'apis' | 'plugins'
225225
export type ResolvedConfig = Omit<RawUniversalConfig, 'apis' | 'plugins'> &
226226
ResolvedGovernanceConfig & {
227227
apis?: Record<string, ResolvedApiConfig>;
228+
plugins?: string[];
228229
};
229230

230231
export type ThemeConfig = {

0 commit comments

Comments
 (0)