Skip to content

Commit

Permalink
Improvements to fix the build
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stuarthendren committed May 24, 2021
1 parent 1d410d9 commit 4b122af
Show file tree
Hide file tree
Showing 21 changed files with 53 additions and 113 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ jobs:
run: npm run lint

- name: Danger
run: npm run danger -- ci
run: npm run danger:pr -- ci
env:
PR: ${{ github.event.number }}
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
Expand Down
10 changes: 6 additions & 4 deletions dangerfile.lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} - <i>${idea}</i>`)
}
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} - <i>${idea}</i>`)
}
Expand All @@ -35,7 +37,7 @@ if (hasSrcChanges && !hasStoriesChanges) {
)
}

const storiesFolderPath = 'stories/components'
const storiesFolderPath = 'src/components'
const hasStories = (folderName) =>
fs
.readdirSync(path.join(storiesFolderPath, folderName))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/${PR}"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0"
Expand Down
31 changes: 31 additions & 0 deletions src/components/Icons/Icons.stories.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Flex css={{ flexWrap: 'wrap' }}>
{icons.map((key) => {
return (
<Copy
css={{ color: '$text' }}
portalled={portalled}
key={key}
content={key}
>
{React.createElement((Icons as Record<string, React.FC>)[key])}
</Copy>
)
})}
</Flex>
)
}
8 changes: 3 additions & 5 deletions src/components/List/List.stories.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/components/List/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export * from './List'
export * from './ListItem'
export * from './ListItemIcon'
export * from './ListItemSecondaryAction'
export * from './ListItemText'
17 changes: 0 additions & 17 deletions src/components/ListItem/ListItem.stories.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/components/ListItem/ListItem.test.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/ListItem/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/components/ListItemIcon/ListItemIcon.test.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/ListItemIcon/index.ts

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/components/ListItemSecondaryAction/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/ListItemText/ListItemText.test.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/ListItemText/index.ts

This file was deleted.

30 changes: 6 additions & 24 deletions src/components/SvgIcon/SvgIcon.stories.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Flex css={{ flexWrap: 'wrap' }}>
{icons.map((key) => {
return (
<Copy
css={{ color: '$text' }}
portalled={portalled}
key={key}
content={key}
>
{React.createElement((Icons as Record<string, React.FC>)[key])}
</Copy>
)
})}
</Flex>
)
}
export const Default: Story = (args) => (
<SvgIcon {...args}>
<path d="M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z" />
</SvgIcon>
)
4 changes: 0 additions & 4 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 4b122af

Please sign in to comment.