Skip to content

Instantly share code, notes, and snippets.

@kaosf
Created March 14, 2013 10:50
Show Gist options
  • Select an option

  • Save kaosf/5160421 to your computer and use it in GitHub Desktop.

Select an option

Save kaosf/5160421 to your computer and use it in GitHub Desktop.
tiapp.xml を切り替えるシェルスクリプト書いたし ref: http://qiita.com/items/a2c57d2e3b216033ad8b
#! /bin/sh
./tiapp_xml-converter $1
ti build # ここは各自でちゃんと書いてね
./tiapp_xml-reverter
hostname: my.development.com
var s = Ti.App.Properties.getString('varname');
alert(s); // alert "mystring"
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
...
<property name="varname" type="string">mystring</property>
...
</ti:app>
#! /bin/sh
BUILD_TYPE=$1
if [ -z "$BUILD_TYPE" ]; then
BUILD_TYPE=production
fi
if [ \
$BUILD_TYPE != 'development' -a \
$BUILD_TYPE != 'staging' -a \
$BUILD_TYPE != 'production' \
]; then
echo 'the argument should be in [development, staging, production]' 1>&2
exit 1
fi
if [ $BUILD_TYPE = 'development' -a ! -e env ]; then
echo "local environment file \"env\" doesn't exist" 1>&2
exit 1
fi
if [ $BUILD_TYPE = 'development' ]; then
HOSTNAME=$(cat env | grep 'hostname:' | awk '{print $2}')
elif [ $BUILD_TYPE = 'staging' ]; then
HOSTNAME=staging.example.com
fi
if [ $BUILD_TYPE != 'production' ]; then
cp tiapp.xml tiapp.xml.bk
sed -e "s/<name>\(.*\?\)<\/name>/<name>\1${BUILD_TYPE}<\/name>/" tiapp.xml -i
sed -e "s/<id>\(.*\?\)<\/id>/<id>\1${BUILD_TYPE}<\/id>/" tiapp.xml -i
sed -e "s/<property name=\"appenv\" type=\"string\">.*\?<\/property>/<property name=\"appenv\" type=\"string\">${BUILD_TYPE}<\/property>/" tiapp.xml -i
sed -e "s/<property name=\"hostname\" type=\"string\">.*\?<\/property>/<property name=\"hostname\" type=\"string\">${HOSTNAME}<\/property>/" tiapp.xml -i
fi
#! /bin/sh
if [ -e tiapp.xml.bk ]; then
mv tiapp.xml.bk tiapp.xml
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment