-
Notifications
You must be signed in to change notification settings - Fork 1
/
_INSTALL.sh
executable file
·155 lines (138 loc) · 4.22 KB
/
_INSTALL.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
# fork/clone this repo with your own LICENSE/README.md files, then run this script
# Exit script as soon as a command fails.
set -o errexit
# FUNCS
check_continue() {
read -p '[y]es to continue: ' do_continue
if [ "$do_continue" != "y" ]; then
echo "Input was not 'y' - exiting"
exit 1
fi
}
# VARS
GITHUB_USER_NAME_DEF="YOUR-GITHUB-USERNAME"
GITHUB_USER_NAME=""
GITHUB_USER_EMAIL_DEF="YOUR-GITHUB-EMAIL"
GITHUB_USER_EMAIL=""
PROJ_NAME="YOUR-PROJ-NAME"
PROJ_DESC="YOUR PROJ DESC"
PROJ_KEYWORDS="'YOUR','PROJ','KEYWORDS'"
PROJ_HOMEPAGE_DEF="https://github.com/$GITHUB_USER_NAME_DEF/$PROJ_NAME"
PROJ_HOMEPAGE=""
PROJ_REPO_URL_DEF="$PROJ_HOMEPAGE_DEF.git"
PROJ_REPO_URL=""
PROJ_BUGS_URL_DEF="$PROJ_HOMEPAGE_DEF/issues"
PROJ_BUGS_URL=""
# MAIN
while getopts ":u:v:n:d:k:h:r:b:" opt; do
case $opt in
u)
GITHUB_USER_NAME="$OPTARG"
if [ "$PROJ_HOMEPAGE" == "" ]; then
PROJ_HOMEPAGE="https://github.com/$GITHUB_USER_NAME/$PROJ_NAME"
if [ "$PROJ_REPO_URL" == "" ]; then
PROJ_REPO_URL="$PROJ_HOMEPAGE.git"
fi
if [ "$PROJ_BUGS_URL" == "" ]; then
PROJ_BUGS_URL="$PROJ_HOMEPAGE/issues"
fi
fi
;;
v)
GITHUB_USER_EMAIL="$OPTARG"
;;
n)
PROJ_NAME="$OPTARG"
;;
d)
PROJ_DESC="$OPTARG"
;;
k)
PROJ_KEYWORDS="$OPTARG"
;;
h)
PROJ_HOMEPAGE="$OPTARG"
;;
r)
PROJ_REPO_URL="$OPTARG"
;;
b)
PROJ_BUGS_URL="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG"
exit 1
;;
esac
done
set +o errexit
git remote show ozs > /dev/null
if [ "$?" == 0 ]; then
echo "git remote 'ozs' exists, so you must have already run this script. Run ./_UPDATE.sh instead!"
exit 1
fi
set -o errexit
echo "git remote 'ozs' doesn't exist yet - configure now?"
check_continue
if [ "$GITHUB_USER_NAME" != "" ]; then
git config user.name "$GITHUB_USER_NAME"
fi
if [ "$GITHUB_USER_EMAIL" != "" ]; then
git config user.email "$GITHUB_USER_EMAIL"
fi
git remote add ozs https://github.com/OpenZeppelin/openzeppelin-solidity.git
#git fetch ozs
#git pull --rebase --allow-unrelated-histories -Xtheirs ozs master
git pull --no-edit --allow-unrelated-histories -Xours ozs master
#git diff --name-only --diff-filter=U | xargs git checkout HEAD # Unmerged, i.e. merge errored due to prior existence/previous deletion
#git diff --name-only --diff-filter=M | xargs git add # Modified, i.e. merged
#git commit -m "openzeppelin-solidity merge" --author="OpenZeppelin <contact@openzeppelin.org>"
if [ "$?" != 0 ]; then
echo "git operation exited with error - exiting"
exit 1
fi
rm -rf CONTRIBUTING.md ethpm.json CODE_OF_CONDUCT.md .github/ audit/ contracts/* test/*/ test/*.test.js
touch contracts/.gitkeep
touch test/.gitkeep
git add . && git commit -m "In the beginning..." # commit any initial files, i.e. this one
# update!
./_UPDATE.sh
if [ "$?" != 0 ]; then
echo "_UPDATE.sh exited with error - exiting"
exit 1
fi
if [ "$GITHUB_USER_NAME" == "" ]; then
GITHUB_USER_NAME="$GITHUB_USER_NAME_DEF"
fi
if [ "$GITHUB_USER_EMAIL" == "" ]; then
GITHUB_USER_EMAIL="$GITHUB_USER_EMAIL_DEF"
fi
if [ "$PROJ_HOMEPAGE" == "" ]; then
PROJ_HOMEPAGE="$PROJ_HOMEPAGE_DEF"
fi
if [ "$PROJ_REPO_URL" == "" ]; then
PROJ_REPO_URL="$PROJ_REPO_URL_DEF"
fi
if [ "$PROJ_BUGS_URL" == "" ]; then
PROJ_BUGS_URL="$PROJ_BUGS_URL_DEF"
fi
npm install -g json
json -I -f package.json -e "this.name='$PROJ_NAME'"
json -I -f package.json -e "this.version='1.0.0'"
json -I -f package.json -e "this.description='$PROJ_DESC'"
json -I -f package.json -e "this.keywords.unshift($PROJ_KEYWORDS)"
json -I -f package.json -e "this.author='$GITHUB_USER_NAME <$GITHUB_USER_EMAIL>'"
json -I -f package.json -e "this.homepage='$PROJ_HOMEPAGE'"
json -I -f package.json -e "this.repository.url='$PROJ_REPO_URL'"
json -I -f package.json -e "this.bugs.url='$PROJ_BUGS_URL'"
npm install openzeppelin-solidity --save-dev # must run this after changing package.json => name (done above)
git add . && git commit -m "initial config"
git checkout --orphan master-new
git add -A
git commit -am "Initial commit"
git branch -D master # delete old master branch
git branch -m master # rename this to master
echo # newline
echo "_INSTALL.sh complete!"
exit 0