Skip to content

Instantly share code, notes, and snippets.

@aprius
Last active July 30, 2019 17:08
Show Gist options
  • Save aprius/fe41040b2bab0dee920bfa027bc3521f to your computer and use it in GitHub Desktop.
Save aprius/fe41040b2bab0dee920bfa027bc3521f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -ue
HOST="gitlab.com"
TYPE="git"
GROUP="yenmoc"
AUTHOR="yenmoc"
LICENSE="MIT"
YEAR=2019
COPYRIGHT_NAME="yenmoc"
TEMPLATE_PACKAGE_NAME="__PACKAGE_NAME__"
TEMPLATE_DISPLAY_NAME="__DISPLAY_PACKAGE_NAME__"
TEMPLATE_UNITY_VERSION="__UNITY_VERSION__"
TEMPLATE_DESCRIPTION="__DESCRIPTION__"
TEMPLATE_READ_ME="__READ_ME__"
TEMPLATE_NAME_FOLDER="__NAME_FOLDER__"
TEMPLATE_AUTHOR_NAME="__AUTHOR_NAME__"
TEMPLATE_REPOSITORY_HOST="__REPOSITORY_HOST__"
TEMPLATE_REPOSITORY_GROUP="__REPOSITORY_GROUP__"
TEMPLATE_REPOSITORY="__REPOSITORY_NAME__"
TEMPLATE_LINCENSE="__LICENSE__"
TEMPLATE_REPOSITORY_TYPE="__REPOSITORY_TYPE__"
TEMPLATE_COPYRIGHT_YEAR="__COPYRIGHT_YEAR__"
TEMPLATE_COPYRIGHT_NAME="__COPYRIGHT_NAME__"
read -p "Scope (ORGANIZATIONS default: ${GROUP}): " SCOPE
if [ -z "$SCOPE" ]; then
SCOPE=$GROUP
fi
read -p "Name: " NAME
read -p "Display Package Name: " DISPLAY_PACKAGE_NAME
read -p "Unity Version (ex 2019.3): " UNITY_VERSION
PACKAGE_NAME="com.${SCOPE}.${NAME}"
read -p "Name folder in packages: " NAME_FOLDER
read -p "Description: " DESCRIPTION
read -p "Read me: " README
if [ -z "$DISPLAY_PACKAGE_NAME" ]; then
DISPLAY_PACKAGE_NAME=$NAME
fi
if [ -z "$NAME_FOLDER" ]; then
NAME_FOLDER=$PACKAGE_NAME
fi
git clone [email protected]:yenmoc/template.git $NAME
cd $NAME
rm -Rf .git/
git init
git remote add origin [email protected]:$SCOPE/$NAME.git
RESULT=""
while read -r line; do
RESULT+="$line"
done < "package.json"
ChangePackageJson(){
RESULT=${RESULT//$TEMPLATE_PACKAGE_NAME/$PACKAGE_NAME}
RESULT=${RESULT//$TEMPLATE_DISPLAY_NAME/$DISPLAY_PACKAGE_NAME}
RESULT=${RESULT//$TEMPLATE_UNITY_VERSION/$UNITY_VERSION}
RESULT=${RESULT//$TEMPLATE_DESCRIPTION/$DESCRIPTION}
RESULT=${RESULT//$TEMPLATE_READ_ME/$README}
RESULT=${RESULT//$TEMPLATE_NAME_FOLDER/$NAME_FOLDER}
RESULT=${RESULT//$TEMPLATE_AUTHOR_NAME/$AUTHOR}
RESULT=${RESULT//$TEMPLATE_REPOSITORY_HOST/$HOST}
RESULT=${RESULT//$TEMPLATE_REPOSITORY_GROUP/$GROUP}
RESULT=${RESULT//$TEMPLATE_REPOSITORY/$NAME}
RESULT=${RESULT//$TEMPLATE_LINCENSE/$LICENSE}
RESULT=${RESULT//$TEMPLATE_REPOSITORY_TYPE/$TYPE}
}
ChangePackageJson
echo $RESULT > package.json
echo "# ${NAME}" > README.md
echo "" >> README.md
echo "## What" >> README.md
echo "* " >> README.md
echo "" >> README.md
echo "## Requirement" >> README.md
echo "* " >> README.md
echo "" >> README.md
echo "## Install" >> README.md
echo "" >> README.md
echo "\`\`\`shell" >> README.md
echo "\"${PACKAGE_NAME}\": \"https://${HOST}:${GROUP}/${NAME}#1.0.0\"" >> README.md
echo "\`\`\`" >> README.md
echo "" >> README.md
echo "## Usage" >> README.md
echo "" >> README.md
echo "* " >> README.md
echo "" >> README.md
echo "## License" >> README.md
echo "" >> README.md
echo "Copyright (c) ${YEAR} ${COPYRIGHT_NAME}" >> README.md
echo "Released under the ${LICENSE} license, see [LICENSE.txt](LICENSE.txt)" >> README.md
cat <<__INSTRUCTION__
🚀 What's next?
cd $NAME
# edit README.md
# edit package.json
git add .
git commit -m ":tada: initialized"
git push origin master
Enjoy your development 🌟
__INSTRUCTION__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment