Skip to content

Instantly share code, notes, and snippets.

@kerrishotts
Created December 6, 2012 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerrishotts/4227648 to your computer and use it in GitHub Desktop.
Save kerrishotts/4227648 to your computer and use it in GitHub Desktop.
Sample wrapper around PhoneGap create command
#!/bin/bash
#
# this is a wrapper around PG's ./create command. It asks for
# each portion separately.
#
# Author: Kerri Shotts
# License: MIT
#
# Get the path to the PhoneGap installation
# let's see if it is defined in the environment first
PGPATH=$PHONEGAP_HOME;
if [ "$PGPATH" = "" ]; then
# not defined; let's see if we've got a ~/.phonegap
PGPATH="`cat ~/.phonegap`"
if [ "$PGPATH" = "" ]; then
# still not defined... we need the user's help
echo
echo "Unable to locate PhoneGap directory from your environment. Please enter"
echo "the directory to PhoneGap, or drag the directory into the terminal."
echo
echo "Please enter PhoneGap directory: "
read PGPATH
fi
fi
if [ -f "${PGPATH}/VERSION" ]; then
# the VERSION file exists
echo "NOTICE: Using PhoneGap version `cat ${PGPATH}/VERSION` in ${PGPATH}";
VERSION=`cat ${PGPATH}/VERSION`;
else
echo "ERROR: No VERSION file in ${PGPATH}; not a valid PhoneGap install.";
exit 9;
fi
#
# Now ask for the project's root directory; it doesn't need to exist
echo
echo "PROJECT DIRECTORY: Please select a directory to house your project. It does"
echo "not need to exist -- if it doesn't, it will be created automatically. If you"
echo "already have a directory created, you can enter the path, or drag the"
echo "directory to the terminal."
echo
echo "Please enter the project's root directory: "
read ROOTDIR
#
# Now ask for the project's domain
echo
echo "PROJECT DOMAIN: Please enter your project's reverse domain. For example,"
echo "for a fully qualified domain of com.example.myapp, enter 'com.example'."
echo
echo "Please enter the project's domain: "
read DOMAIN
#
# Now ask for the project's name
echo
echo "PROJECT NAME: Please enter the name of your project."
echo
echo "Please enter the project's name: "
read APPNAME
#
# What platform?
echo
echo "PLATFORM: What platform are you creating this project for?"
echo
echo " ios: iPad, iPhone, iPod, etc."
echo " android: Android devices."
echo
echo "Please enter the platform: "
read PLATFORM
echo "... creating a project for ${PLATFORM}"
mkdir -p "${ROOTDIR}/${PLATFORM}"
if [ "${PLATFORM}" = "android" ]; then
"${PGPATH}/lib/${PLATFORM}/bin/create" "${ROOTDIR}/${PLATFORM}/${APPNAME}" "${DOMAIN}.${APPNAME}" "${APPNAME}"
else
"${PGPATH}/lib/${PLATFORM}/bin/create" "${ROOTDIR}/${PLATFORM}" "${DOMAIN}.${APPNAME}" "${APPNAME}"
fi
echo "... Project creation complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment