Skip to content

Commit

Permalink
Add keywords to plugin logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 29, 2022
1 parent 4e1e48b commit 0fa92cb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/config/plugin/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ export const normalizePluginConfig = async function ({
pluginConfig: unmergedConfig,
plugin,
pluginConfigRules,
opts: { name, sharedConfig, sharedConfigName, context, cwd, shared, prefix },
opts: {
name,
sharedConfig,
sharedConfigName,
context,
cwd,
shared,
prefix,
keywords,
},
}) {
const pluginConfig = deepMergePair(sharedConfig, unmergedConfig)

Expand All @@ -53,6 +62,7 @@ export const normalizePluginConfig = async function ({
plugin,
prefix,
parent,
keywords,
})
const pluginConfigB = await normalizeSpecificConfig({
pluginConfig: pluginConfigA,
Expand All @@ -62,6 +72,7 @@ export const normalizePluginConfig = async function ({
cwd,
prefix,
parent,
keywords,
})
return pluginConfigB
}
Expand All @@ -83,10 +94,12 @@ const normalizeSharedConfig = async function ({
plugin,
prefix,
parent,
keywords,
}) {
const dummyRules = getDummyRules(pluginConfigRules)
return await safeNormalizeConfig(pluginConfig, [...shared, ...dummyRules], {
all: { cwd, prefix, parent, context: { ...context, plugin } },
keywords,
UserErrorType: ConsumerError,
SystemErrorType: UserError,
})
Expand All @@ -100,13 +113,15 @@ const normalizeSpecificConfig = async function ({
cwd,
prefix,
parent,
keywords,
}) {
const dummyRules = getDummyRules(shared)
return await safeNormalizeConfig(
pluginConfig,
[...dummyRules, ...pluginConfigRules],
{
all: { cwd, prefix, parent, context },
keywords,
UserErrorType: ConsumerError,
SystemErrorType: PluginError,
},
Expand Down
3 changes: 2 additions & 1 deletion src/config/plugin/lib/location_normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { safeNormalizeConfig } from './normalize.js'

// Normalize `pluginConfig[pluginProp]`
export const normalizeLocation = async function ({
opts: { cwd, builtins, modulePrefix, prefix },
opts: { cwd, builtins, modulePrefix, prefix, keywords },
originalLocation,
locationName,
locationType,
Expand All @@ -17,6 +17,7 @@ export const normalizeLocation = async function ({
parent: locationName,
context: { locationType, builtins, modulePrefix },
},
keywords,
UserErrorType: ConsumerError,
SystemErrorType: CoreError,
})
Expand Down
2 changes: 2 additions & 0 deletions src/config/plugin/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const normalizeSingleOpts = function ({
prefix,
context,
cwd,
keywords,
}) {
const { sharedConfig: sharedConfigA, sharedPropNames } = getSharedConfig(
sharedConfig,
Expand All @@ -45,5 +46,6 @@ export const normalizeSingleOpts = function ({
prefix,
context,
cwd,
keywords,
}
}
4 changes: 3 additions & 1 deletion src/config/plugin/lib/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ export const normalizeShape = async function ({
plugin,
locationType,
originalLocation,
opts: { shape, sharedPropNames, context },
opts: { shape, sharedPropNames, context, keywords },
}) {
const pluginA = await safeNormalizeConfig(plugin, COMMON_SHAPE_RULES, {
all: {
prefix: PLUGIN_PREFIX,
context: { sharedPropNames, locationType, originalLocation },
},
keywords,
UserErrorType: PluginError,
SystemErrorType: CoreError,
})
Expand All @@ -29,6 +30,7 @@ export const normalizeShape = async function ({
[...getDummyRules(COMMON_SHAPE_RULES), ...shape],
{
all: { prefix: PLUGIN_PREFIX, context },
keywords,
UserErrorType: PluginError,
SystemErrorType: UserError,
},
Expand Down
3 changes: 2 additions & 1 deletion src/config/plugin/lib/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { safeNormalizeConfig } from './normalize.js'
// one if it uses the string shortcut syntax.
export const normalizePluginConfigTop = async function (
pluginConfig,
{ name, cwd, pluginProp, builtins, prefix },
{ name, cwd, pluginProp, builtins, prefix, keywords },
) {
const locationName =
typeof pluginConfig === 'string' ? name : `${name}.${pluginProp}`
const { [pluginProp]: originalLocation, ...pluginConfigA } =
await safeNormalizeConfig(pluginConfig, [normalizeTop], {
all: { cwd, prefix, parent: name, context: { pluginProp, builtins } },
keywords,
UserErrorType: ConsumerError,
SystemErrorType: CoreError,
})
Expand Down

0 comments on commit 0fa92cb

Please sign in to comment.