website: enable plugin tier override (#10919)
* website: enable plugin tier override * website: validate remote plugins config pluginTier
This commit is contained in:
parent
d22ba61ae0
commit
cbe06050b4
|
@ -20,6 +20,7 @@ async function checkPluginDocs() {
|
|||
console.log(`\n${COLOR_BLUE}${repo}${COLOR_RESET} | ${title}`);
|
||||
console.log(`Fetching docs from release "${version}" …`);
|
||||
try {
|
||||
// Validate that all required properties are present
|
||||
const undefinedProps = ["title", "repo", "version", "path"].filter(
|
||||
(key) => typeof pluginEntry[key] == "undefined"
|
||||
);
|
||||
|
@ -34,6 +35,22 @@ async function checkPluginDocs() {
|
|||
)} are defined. Additional information on this configuration can be found in "website/README.md".`
|
||||
);
|
||||
}
|
||||
// Validate pluginTier property
|
||||
const { pluginTier } = pluginEntry;
|
||||
if (typeof pluginTier !== "undefined") {
|
||||
const validPluginTiers = ["official", "community"];
|
||||
const isValid = validPluginTiers.indexOf(pluginTier) !== -1;
|
||||
if (!isValid) {
|
||||
throw new Error(
|
||||
`Failed to validate plugin docs config. Invalid pluginTier "${pluginTier}" found for "${
|
||||
title || pluginEntry.path || repo
|
||||
}". In "website/data/docs-remote-plugins.json", the optional pluginTier property must be one of ${JSON.stringify(
|
||||
validPluginTiers
|
||||
)}. The pluginTier property can also be omitted, in which case it will be determined from the plugin repository owner.`
|
||||
);
|
||||
}
|
||||
}
|
||||
// Attempt to fetch plugin docs files
|
||||
const docsMdxFiles = await fetchPluginDocs({ repo, tag: version });
|
||||
const mdxFilesByComponent = docsMdxFiles.reduce((acc, mdxFile) => {
|
||||
const componentType = mdxFile.filePath.split("/")[1];
|
||||
|
|
|
@ -137,6 +137,7 @@ async function resolvePluginEntryDocs(pluginConfigEntry, currentPath) {
|
|||
path: slug,
|
||||
repo,
|
||||
version,
|
||||
pluginTier,
|
||||
sourceBranch = 'main',
|
||||
} = pluginConfigEntry
|
||||
const docsMdxFiles = await fetchPluginDocs({ repo, tag: version })
|
||||
|
@ -164,13 +165,14 @@ async function resolvePluginEntryDocs(pluginConfigEntry, currentPath) {
|
|||
const sourceUrl = `https://github.com/${repo}/blob/${sourceBranch}/${filePath}`
|
||||
// determine pluginTier
|
||||
const pluginOwner = repo.split('/')[0]
|
||||
const pluginTier = pluginOwner === 'hashicorp' ? 'official' : 'community'
|
||||
const parsedPluginTier =
|
||||
pluginTier || (pluginOwner === 'hashicorp' ? 'official' : 'community')
|
||||
// Construct and return a NavLeafRemote node
|
||||
return {
|
||||
title,
|
||||
path: urlPath,
|
||||
remoteFile: { filePath, fileString, sourceUrl },
|
||||
pluginTier,
|
||||
pluginTier: parsedPluginTier,
|
||||
}
|
||||
})
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue