From d87bc6ad23019b0209026cf0a8cdf5834a1013e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serta=C3=A7=20Karahoda?= Date: Mon, 8 Nov 2021 09:33:14 +0300 Subject: [PATCH] refactor: Remove styleguidist --- src/commands/connect/config.ts | 5 +---- src/commands/connect/interfaces/plugin.d.ts | 14 ++------------ src/commands/connect/plugin.ts | 16 ++-------------- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/commands/connect/config.ts b/src/commands/connect/config.ts index 0f60154..cc1e47a 100644 --- a/src/commands/connect/config.ts +++ b/src/commands/connect/config.ts @@ -19,10 +19,7 @@ const componentConfigSchema = Joi.object({ path: Joi.string(), zeplinNames: Joi.array().items(Joi.string()).optional(), zeplinIds: Joi.array().items(Joi.string()).optional(), - name: Joi.string().optional(), - styleguidist: Joi.object({ - name: Joi.string() - }).optional() + name: Joi.string().optional() }).or("zeplinNames", "zeplinIds"); const gitConfigSchema = Joi.object({ diff --git a/src/commands/connect/interfaces/plugin.d.ts b/src/commands/connect/interfaces/plugin.d.ts index b752958..0e28df2 100644 --- a/src/commands/connect/interfaces/plugin.d.ts +++ b/src/commands/connect/interfaces/plugin.d.ts @@ -3,7 +3,7 @@ import { PrismLang } from "./prism"; /** * @public */ -interface LeveledLogMethod { +export interface LeveledLogMethod { (message: string): void; (message: string, meta: unknown): void; (message: string, ...meta: any[]): void; @@ -46,7 +46,6 @@ export interface Link { * @public */ export const enum LinkType { - styleguidist = "styleguidist", storybook = "storybook", github = "github", gitlab = "gitlab", @@ -70,13 +69,6 @@ export interface ComponentData { links?: Link[]; } -/** - * @public - */ -export interface StyleguidistComponentConfig { - name: string; -} - /** * Arbitrary key/values for custom plugin configuration. * @@ -100,8 +92,6 @@ export interface ComponentConfigBase { zeplinIds?: string[]; /** Name for the component */ name?: string; - /** Styleguidist name for the component (Optional) */ - styleguidist?: StyleguidistComponentConfig; } /** @@ -178,4 +168,4 @@ export interface Logger { warn: LeveledLogMethod; info: LeveledLogMethod; debug: LeveledLogMethod; -} \ No newline at end of file +} diff --git a/src/commands/connect/plugin.ts b/src/commands/connect/plugin.ts index 03d9962..2c6d5a7 100644 --- a/src/commands/connect/plugin.ts +++ b/src/commands/connect/plugin.ts @@ -18,13 +18,6 @@ import { getInstallCommand } from "../../util/text"; import { flat } from "../../util/array"; import { isDefined } from "../../util/object"; -const ALLOWED_LINK_TYPES = [ - LinkType.styleguidist, - LinkType.storybook, - LinkType.github, - LinkType.custom -]; - interface ConnectPluginConstructor { new(): ConnectPluginInstance; } @@ -85,7 +78,7 @@ const initializePlugins = async ( }; const processLink = (link: Link): Link => { - if (!ALLOWED_LINK_TYPES.includes(link.type)) { + if (![LinkType.custom].includes(link.type)) { link.type = LinkType.custom; } @@ -209,12 +202,7 @@ const componentConfigToConnectedComponentItems = ({ const createLinksFromConfigFile = ( component: ComponentConfig, componentConfigFile: ComponentConfigFile -): Link[] => (componentConfigFile.links || []).map(({ name, type, url }): Link | undefined => { - // TODO: remove styleguidist specific configuration from CLI core - if (type === "styleguidist" && component.styleguidist) { - const encodedKind = encodeURIComponent(component.styleguidist.name); - return { name, type: LinkType.styleguidist, url: urljoin(url, `#${encodedKind}`) }; - } +): Link[] => (componentConfigFile.links || []).map(({ name, type, url }) => { if (component[type]) { const customUrlPath = (component[type] as CustomUrlConfig).urlPath; if (customUrlPath) {