Skip to content

Commit

Permalink
refactor: Remove styleguidist
Browse files Browse the repository at this point in the history
  • Loading branch information
Sertaç Karahoda committed Nov 8, 2021
1 parent 040d8ee commit d87bc6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
5 changes: 1 addition & 4 deletions src/commands/connect/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
14 changes: 2 additions & 12 deletions src/commands/connect/interfaces/plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,7 +46,6 @@ export interface Link {
* @public
*/
export const enum LinkType {
styleguidist = "styleguidist",
storybook = "storybook",
github = "github",
gitlab = "gitlab",
Expand All @@ -70,13 +69,6 @@ export interface ComponentData {
links?: Link[];
}

/**
* @public
*/
export interface StyleguidistComponentConfig {
name: string;
}

/**
* Arbitrary key/values for custom plugin configuration.
*
Expand All @@ -100,8 +92,6 @@ export interface ComponentConfigBase {
zeplinIds?: string[];
/** Name for the component */
name?: string;
/** Styleguidist name for the component (Optional) */
styleguidist?: StyleguidistComponentConfig;
}

/**
Expand Down Expand Up @@ -178,4 +168,4 @@ export interface Logger {
warn: LeveledLogMethod;
info: LeveledLogMethod;
debug: LeveledLogMethod;
}
}
16 changes: 2 additions & 14 deletions src/commands/connect/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d87bc6a

Please sign in to comment.