-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-chart
executable file
·44 lines (36 loc) · 1.47 KB
/
make-chart
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
#!/bin/bash
set -e
echo "Let's make a new chart."
printf "Enter the name of your chart, in dash-case: "; read CHARTDASH
printf "Enter the name of your chart, in english (ie, \`My chart\`): "; read CHARTTITLE
printf "Describe your chart: "; read CHARTDESC
CHARTUPPERCAMEL="$(echo "$CHARTDASH" | perl -pe 's/(^|-)./uc($&)/ge;s/_//g' | sed 's/-//g')"
first="$(echo $CHARTUPPERCAMEL | cut -c1 | tr [A-Z] [a-z])"
second="$(echo $CHARTUPPERCAMEL | cut -c2-)"
CHARTCAMEL="$first$second"
echo "* Copying template to charts/$CHARTDASH..."
cp -R charts/template charts/$CHARTDASH
echo "* Replacing placeholders with variations of $CHARTDASH..."
for f in $(ls charts/$CHARTDASH); do
sed \
-i .bkp \
-e "s/%CHARTDASH%/$CHARTDASH/g" \
-e "s/%CHARTCAMEL%/$CHARTCAMEL/g" \
-e "s/%CHARTTITLE%/$CHARTTITLE/g" \
-e "s/%CHARTUPPERCAMEL%/$CHARTUPPERCAMEL/g" \
-e "s/%CHARTDESC%/$CHARTDESC/g" \
charts/$CHARTDASH/$f
rm -f charts/$CHARTDASH/$f.bkp
done
echo "* Linking $CHARTDASH story to stories folder..."
cd stories
ln -s ../charts/$CHARTDASH/story.js $CHARTDASH.js
cd ..
echo "Done!"
echo "You have a new chart in charts/$CHARTDASH:"
echo "* charts/$CHARTDASH/index.js contains your chart code."
echo "* charts/$CHARTDASH/styles.scss contains your chart styles."
echo "* charts/$CHARTDASH/story.js contains your react-storyboard story. Use it to present different states of your chart."
echo
echo "To build the storyboard and start a development server:"
echo "=> npm run storyboard"