-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeComponentsFile.sh
59 lines (47 loc) · 1.56 KB
/
makeComponentsFile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
echo "\n========コンポーネントを作成します========\n"
COMPONENTS_DIR='src/components'
if [ ! -d $COMPONENTS_DIR ];then
mkdir $COMPONENTS_DIR
fi
echo '📝 コンポーネントの種類を入力してください'
PS3='(number): '
select GENRE in 'ui-elements' 'ui-parts'
do
if [ ! -d $COMPONENTS_DIR/$GENRE ];then
echo ✅ $GENRE ディレクトリを作成しました。
mkdir $COMPONENTS_DIR/$GENRE
fi
break
done
echo '\n📝 コンポーネント名を入力してください(例: Button): '
read COMPONENTS_NAME
echo ''
if [ -d $COMPONENTS_DIR/$GENRE/$COMPONENTS_NAME ];then
echo ❌ $COMPONENTS_NAME ディレクトリが存在します。最初からやり直してください。
exit 1
fi
mkdir $COMPONENTS_DIR/$GENRE/$COMPONENTS_NAME
cat <<EOF > $COMPONENTS_DIR/$GENRE/$COMPONENTS_NAME/index.tsx
import { VFC } from 'react';
type Props = {};
const $COMPONENTS_NAME: VFC<Props> = ({ }) => {
return (
<></>
)
};
export default $COMPONENTS_NAME;
EOF
echo ✅ $COMPONENTS_NAME/index.tsx を作成しました
cat <<EOF > $COMPONENTS_DIR/$GENRE/$COMPONENTS_NAME/$COMPONENTS_NAME.stories.tsx
import { ComponentStory, ComponentMeta } from '@storybook/react';
import $COMPONENTS_NAME from './index';
export default {
title: '$GENRE/$COMPONENTS_NAME',
component: $COMPONENTS_NAME,
} as ComponentMeta<typeof $COMPONENTS_NAME>;
export const Default1: ComponentStory<typeof $COMPONENTS_NAME> = () => (
<$COMPONENTS_NAME></$COMPONENTS_NAME>
);
EOF
echo ✅ $COMPONENTS_NAME/$COMPONENTS_NAME.stories.tsx を作成しました