This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·86 lines (67 loc) · 2.24 KB
/
configure
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
echo ""
echo "STARTER KIT"
echo "==========="
echo ""
echo "Configuratoring code for your new project..."
echo ""
dir=$(echo ${PWD##*/} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z)
if [ $dir == "starter-kit" ]
then
echo "DANGER: the directory name is \"$dir\""
read -e -n 1 -p "Are you sure you want to continue? [y/N] : " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Exiting"
exit;
fi
fi
read -p "New Github repo name (press enter to use default \"$dir\") : " name
read -p "Description of the project displayed on Github : " description
repo=$(echo ${name:-$dir} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z)
rev=$(git rev-parse --short HEAD)
defaulturl="https://ig.ft.com/sites/${repo}"
read -p "Live URL (press enter for default \"${defaulturl}\") : " url
read -p "If you have a Link File UUID paste if here: " uuid
url=${url:-$defaulturl}
if [[ ! $url =~ ^https?\:\/\/ ]]
then
url="https://ig.ft.com/sites/${url}"
fi
echo "Setting URL to $url"
template_str=$(cat readme.md.template)
if [ -n "$uuid" ]
then
echo "Adding $uuid to ./uuid file"
echo $uuid > uuid
fi
echo "Trash git history for starter-kit"
rm -rf .git
echo "Delete $(rm -rfv configure readme.md.template)"
echo "Directory: $dir"
echo "Repo name: $repo"
eval "echo \"${template_str}\"" > README.md
eval "echo \"$(cat config/article.js)\"" > config/article.js
git init
git add .
git commit -m "Initial commit: uses starter kit (commit $rev)"
echo "Installing dependencies..."
npm i --link --no-optional
echo "Creating repo on Github"
RESP=$(curl -n -v https://api.github.com/orgs/ft-interactive/repos \
-d "{\"name\": \"${repo}\", \"homepage\":\"${url}\",\"description\": \"${description}\", \"private\":true, \"team_id\":260487, \"has_issues\": true, \"has_downloads\": true, \"has_wiki\": false}" | node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).message")
echo $RESP
git remote add origin ssh://git@github.com/ft-interactive/$repo.git
if [[ $RESP =~ "upgrade your plan" ]];
then
echo ""
echo "No more private repos 😭 -- please manually create repo and then run:"
echo ""
echo " git push origin master"
else
echo "Push to Github"
git push origin master -u
echo ""
echo "DONE !!"
echo ""
fi