From 96fe5758c671048a859b1f0d59d3c090479b64f8 Mon Sep 17 00:00:00 2001 From: Stuart Hendren Date: Mon, 24 May 2021 16:37:25 +0000 Subject: [PATCH] Improvements to fix the build Move List dependencies to same file as removes the story danger requirement. Changes danger to use the package-lock Updates the story reverence in the dangerfile Update the github build script. see #81 --- .github/workflows/build.yml | 2 +- dangerfile.lite.ts | 10 +++--- package.json | 2 +- src/components/Icons/Icons.stories.tsx | 31 +++++++++++++++++++ src/components/List/List.stories.tsx | 8 ++--- .../{ListItem => List}/ListItem.tsx | 0 .../{ListItemIcon => List}/ListItemIcon.tsx | 0 .../ListItemSecondaryAction.tsx | 0 .../{ListItemText => List}/ListItemText.tsx | 0 src/components/List/index.ts | 4 +++ src/components/ListItem/ListItem.stories.tsx | 17 ---------- src/components/ListItem/ListItem.test.tsx | 13 -------- src/components/ListItem/index.ts | 1 - .../ListItemIcon/ListItemIcon.test.tsx | 13 -------- src/components/ListItemIcon/index.ts | 1 - .../ListItemSecondaryAction.test.tsx | 13 -------- .../ListItemSecondaryAction/index.ts | 1 - .../ListItemText/ListItemText.test.tsx | 14 --------- src/components/ListItemText/index.ts | 1 - src/components/SvgIcon/SvgIcon.stories.tsx | 30 ++++-------------- src/components/index.ts | 4 --- 21 files changed, 52 insertions(+), 113 deletions(-) create mode 100644 src/components/Icons/Icons.stories.tsx rename src/components/{ListItem => List}/ListItem.tsx (100%) rename src/components/{ListItemIcon => List}/ListItemIcon.tsx (100%) rename src/components/{ListItemSecondaryAction => List}/ListItemSecondaryAction.tsx (100%) rename src/components/{ListItemText => List}/ListItemText.tsx (100%) delete mode 100644 src/components/ListItem/ListItem.stories.tsx delete mode 100644 src/components/ListItem/ListItem.test.tsx delete mode 100644 src/components/ListItem/index.ts delete mode 100644 src/components/ListItemIcon/ListItemIcon.test.tsx delete mode 100644 src/components/ListItemIcon/index.ts delete mode 100644 src/components/ListItemSecondaryAction/ListItemSecondaryAction.test.tsx delete mode 100644 src/components/ListItemSecondaryAction/index.ts delete mode 100644 src/components/ListItemText/ListItemText.test.tsx delete mode 100644 src/components/ListItemText/index.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 131146a3..df2bfce1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: run: npm run lint - name: Danger - run: npm run danger -- ci + run: npm run danger:pr -- ci env: DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dangerfile.lite.ts b/dangerfile.lite.ts index 61453d1c..7837670d 100644 --- a/dangerfile.lite.ts +++ b/dangerfile.lite.ts @@ -13,14 +13,16 @@ const allFiles = [...modifiedFiles, ...newFiles] // Keep lockfile up to date const packageChanged = includes(modifiedFiles, 'package.json') -const lockfileChanged = includes(modifiedFiles, 'yarn.lock') +const lockfileChanged = includes(modifiedFiles, 'package-lock.json') if (packageChanged && !lockfileChanged) { - const message = 'Changes were made to package.json, but not to yarn.lock' + const message = + 'Changes were made to package.json, but not to package-lock.json' const idea = 'Perhaps you need to run `yarn install` or commit the lockfile?' warn(`${message} - ${idea}`) } if (!packageChanged && lockfileChanged) { - const message = 'Changes were made to yarn.lock, but not to package.json' + const message = + 'Changes were made to package-lock.json, but not to package.json' const idea = 'Perhaps you need to commit the package.json?' warn(`${message} - ${idea}`) } @@ -35,7 +37,7 @@ if (hasSrcChanges && !hasStoriesChanges) { ) } -const storiesFolderPath = 'stories/components' +const storiesFolderPath = 'src/components' const hasStories = (folderName) => fs .readdirSync(path.join(storiesFolderPath, folderName)) diff --git a/package.json b/package.json index 264c8301..d7c3d8dc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "format": "prettier --write '**/{src,test,stories}/**/{*.js,*.ts,*.tsx,*.json,*.md,*.mdx}' example/index.tsx", "deploy-storybook": "storybook-to-ghpages", "danger:local": "danger local -b main --dangerfile dangerfile.lite.ts", - "danger:pr": "cross-env DANGER_GITHUB_API_TOKEN=${GITHUB_TOKEN} danger pr https://github.com/commitd/components/pull/${PR}" + "danger:pr": "danger pr https://github.com/commitd/components/pull/${{github.event.number}}" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0" diff --git a/src/components/Icons/Icons.stories.tsx b/src/components/Icons/Icons.stories.tsx new file mode 100644 index 00000000..a2b86b83 --- /dev/null +++ b/src/components/Icons/Icons.stories.tsx @@ -0,0 +1,31 @@ +import { Meta, Story } from '@storybook/react' +import React from 'react' +import { Flex, SvgIcon } from '..' +import { Copy, usePortalled } from '../../docs/util' +import * as Icons from './' + +export default { + title: 'Components/Icons', + component: SvgIcon, +} as Meta + +export const Default: Story = (_args, context) => { + const portalled = usePortalled(context) + const icons = Object.keys(Icons).filter((name) => /[A-Z]/.test(name[0])) + return ( + + {icons.map((key) => { + return ( + + {React.createElement((Icons as Record)[key])} + + ) + })} + + ) +} diff --git a/src/components/List/List.stories.tsx b/src/components/List/List.stories.tsx index ed2a5274..16b7406e 100644 --- a/src/components/List/List.stories.tsx +++ b/src/components/List/List.stories.tsx @@ -1,15 +1,13 @@ import React from 'react' import { Meta } from '@storybook/react' -import { List } from '.' import { - Box, - Button, - Flex, + List, ListItem, ListItemIcon, ListItemSecondaryAction, ListItemText, -} from '..' +} from '.' +import { Box, Button, Flex } from '..' import { Check } from '../Icons' diff --git a/src/components/ListItem/ListItem.tsx b/src/components/List/ListItem.tsx similarity index 100% rename from src/components/ListItem/ListItem.tsx rename to src/components/List/ListItem.tsx diff --git a/src/components/ListItemIcon/ListItemIcon.tsx b/src/components/List/ListItemIcon.tsx similarity index 100% rename from src/components/ListItemIcon/ListItemIcon.tsx rename to src/components/List/ListItemIcon.tsx diff --git a/src/components/ListItemSecondaryAction/ListItemSecondaryAction.tsx b/src/components/List/ListItemSecondaryAction.tsx similarity index 100% rename from src/components/ListItemSecondaryAction/ListItemSecondaryAction.tsx rename to src/components/List/ListItemSecondaryAction.tsx diff --git a/src/components/ListItemText/ListItemText.tsx b/src/components/List/ListItemText.tsx similarity index 100% rename from src/components/ListItemText/ListItemText.tsx rename to src/components/List/ListItemText.tsx diff --git a/src/components/List/index.ts b/src/components/List/index.ts index df6b726b..f3c2fcab 100644 --- a/src/components/List/index.ts +++ b/src/components/List/index.ts @@ -1 +1,5 @@ export * from './List' +export * from './ListItem' +export * from './ListItemIcon' +export * from './ListItemSecondaryAction' +export * from './ListItemText' diff --git a/src/components/ListItem/ListItem.stories.tsx b/src/components/ListItem/ListItem.stories.tsx deleted file mode 100644 index 3f2af499..00000000 --- a/src/components/ListItem/ListItem.stories.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react' -import { Story, Meta } from '@storybook/react' -import { ListItem, ListItemProps } from '.' - -export default { - title: 'Components/ListItem', - component: ListItem, -} as Meta - -export const Default: React.FC = () => { - return -} - -const Template: Story = (args) => - -export const Primary = Template.bind({}) -Primary.args = {} diff --git a/src/components/ListItem/ListItem.test.tsx b/src/components/ListItem/ListItem.test.tsx deleted file mode 100644 index 50f41b8c..00000000 --- a/src/components/ListItem/ListItem.test.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react' -import { renderLight, renderDark } from 'test-utils' -import { Default } from './ListItem.stories' - -it('renders light without error', () => { - const { asFragment } = renderLight() - expect(asFragment()).toBeDefined() -}) - -it('renders dark without error', () => { - const { asFragment } = renderDark() - expect(asFragment()).toBeDefined() -}) diff --git a/src/components/ListItem/index.ts b/src/components/ListItem/index.ts deleted file mode 100644 index 24475e27..00000000 --- a/src/components/ListItem/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ListItem' diff --git a/src/components/ListItemIcon/ListItemIcon.test.tsx b/src/components/ListItemIcon/ListItemIcon.test.tsx deleted file mode 100644 index 003eb1e0..00000000 --- a/src/components/ListItemIcon/ListItemIcon.test.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react' -import { renderLight, renderDark } from 'test-utils' -import { ListItemIcon } from '..' - -it('renders light without error', () => { - const { asFragment } = renderLight() - expect(asFragment()).toBeDefined() -}) - -it('renders dark without error', () => { - const { asFragment } = renderDark() - expect(asFragment()).toBeDefined() -}) diff --git a/src/components/ListItemIcon/index.ts b/src/components/ListItemIcon/index.ts deleted file mode 100644 index 40b7ebdc..00000000 --- a/src/components/ListItemIcon/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ListItemIcon' diff --git a/src/components/ListItemSecondaryAction/ListItemSecondaryAction.test.tsx b/src/components/ListItemSecondaryAction/ListItemSecondaryAction.test.tsx deleted file mode 100644 index f9766600..00000000 --- a/src/components/ListItemSecondaryAction/ListItemSecondaryAction.test.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react' -import { renderLight, renderDark } from 'test-utils' -import { ListItemSecondaryAction } from './ListItemSecondaryAction' - -it('renders light without error', () => { - const { asFragment } = renderLight() - expect(asFragment()).toBeDefined() -}) - -it('renders dark without error', () => { - const { asFragment } = renderDark() - expect(asFragment()).toBeDefined() -}) diff --git a/src/components/ListItemSecondaryAction/index.ts b/src/components/ListItemSecondaryAction/index.ts deleted file mode 100644 index 907d9829..00000000 --- a/src/components/ListItemSecondaryAction/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ListItemSecondaryAction' diff --git a/src/components/ListItemText/ListItemText.test.tsx b/src/components/ListItemText/ListItemText.test.tsx deleted file mode 100644 index 4baa4b92..00000000 --- a/src/components/ListItemText/ListItemText.test.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import { renderLight, renderDark } from 'test-utils' - -import { ListItemText } from '.' - -it('renders light without error', () => { - const { asFragment } = renderLight() - expect(asFragment()).toBeDefined() -}) - -it('renders dark without error', () => { - const { asFragment } = renderDark() - expect(asFragment()).toBeDefined() -}) diff --git a/src/components/ListItemText/index.ts b/src/components/ListItemText/index.ts deleted file mode 100644 index 73539878..00000000 --- a/src/components/ListItemText/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ListItemText' diff --git a/src/components/SvgIcon/SvgIcon.stories.tsx b/src/components/SvgIcon/SvgIcon.stories.tsx index 7116b126..db72d9bd 100644 --- a/src/components/SvgIcon/SvgIcon.stories.tsx +++ b/src/components/SvgIcon/SvgIcon.stories.tsx @@ -1,32 +1,14 @@ import { Meta, Story } from '@storybook/react' import React from 'react' import { SvgIcon } from '.' -import { Flex } from '..' -import { Copy, usePortalled } from '../../docs/util' -import * as Icons from '../Icons' export default { - title: 'Components/Icons', + title: 'Components/SvgIcon', component: SvgIcon, } as Meta -export const Default: Story = (_args, context) => { - const portalled = usePortalled(context) - const icons = Object.keys(Icons).filter((name) => /[A-Z]/.test(name[0])) - return ( - - {icons.map((key) => { - return ( - - {React.createElement((Icons as Record)[key])} - - ) - })} - - ) -} +export const Default: Story = (args) => ( + + + +) diff --git a/src/components/index.ts b/src/components/index.ts index 5baf5ef6..49d43734 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -15,10 +15,6 @@ export * from './Icons' export * from './Input' export * from './Link' export * from './List' -export * from './ListItem' -export * from './ListItemIcon' -export * from './ListItemSecondaryAction' -export * from './ListItemText' export * from './RadioGroup' export * from './Slider' export * from './Subheading'