Last active
November 23, 2020 18:35
-
-
Save GinoVillalpando/aaca9be5d6c20de971c65e89f126d553 to your computer and use it in GitHub Desktop.
create vue app script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Print usage statement with option error message | |
function usage { | |
message=$1 | |
if [ "$message" != "" ]; then | |
echo "$message" | |
fi | |
echo -e "\nUsage: $0 <project-name>" | |
exit 1 | |
} | |
# Set project name variable; validate name | |
echo -e "\nChecking for valid project name..." | |
projectName=$1 | |
if [ "$projectName" == "" ]; then | |
usage "No project name provided." | |
fi | |
if [ -d $projectName ]; then | |
usage "Project $projectName already exists." | |
fi | |
echo "Success" | |
# Check if GitHub CLI is installed | |
githubCLI=gh | |
ghSpec=$(which $githubCLI 2>/dev/null) | |
if [ "$ghSpec" == "" ]; then | |
usage "Unable to find GitHub CLI $githubCLI. See for https://cli.github.com for installation instructions" | |
fi | |
# Check that GitHub CLI is configured to use SSH | |
gitProtocol=$(gh config get git_protocol) | |
if [ "$gitProtocol" != "ssh" ]; then | |
gh config set -h github.com git_protocol ssh | |
fi | |
# Create directory and change into it | |
echo -e "\nCreating project '$projectName'" | |
gh repo create -y --private --template rs21io/react-project-template rs21io/$projectName | |
gh repo clone rs21io/$projectName | |
cd $projectName | |
# Check that npm is installed | |
echo -e "\nChecking for npm..." | |
npmExecutable=npm | |
npmSpec=$(which $npmExecutable 2>/dev/null) | |
if [ "$npmSpec" == "" ]; then | |
usage "Unable to find $npmExecutable. Install and re-run." | |
fi | |
echo "npm found" | |
# Create app | |
npx @vue/cli create . --preset rs21io/vue-preset | |
y | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment