Skip to content

Commit

Permalink
making appify work on Lion and be awesomer
Browse files Browse the repository at this point in the history
  • Loading branch information
subtleGradient committed Dec 2, 2011
1 parent 9429eac commit d843430
Showing 1 changed file with 57 additions and 17 deletions.
74 changes: 57 additions & 17 deletions appify-4
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,85 @@
Appify="$(basename "$0")"

if [ ! "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
Appify v4.1 for Mac OS X
Appify v5 for Mac OS X
Creates the simplest possible Mac OS X app from a shell script.
Takes a shell script as its first argument:
$Appify path/to/my-script
NOTE: You cannot rename appified apps, blame Mac OS X.
If you want to give your app a custom name, use the second argument:
$Appify path/to/my-script "My App"
$Appify my-demo "This is my awesome DEMO"
Once your app is created, $Appify will tell you the path to your Info.plist.
You should customize the Bundle Identifier and Get Info String at least.
Copyright © 2010-2011 Thomas Aylott <http://subtlegradient.com>
Copyright © 2011 Mathias Bynens <http://mathiasbynens.be>
Copyright © 2011 Sencha, Inc.
Copyright © 2011 Sencha Labs Foundation
EOF
exit; fi

FILE="$1"
NAME="${2:-$(basename "$FILE" .sh)}"
ROOT="$NAME.app/Contents/MacOS"

if [[ -a "$NAME.app" ]]; then
echo "$PWD/$NAME.app already exists :(" 1>&2
# Options
appify_SRC="$1"
appify_FILE="$(basename $appify_SRC)"
appify_NAME="${2:-$(echo "$appify_FILE"| sed -E 's/\.[a-z]{2,4}$//' )}"
appify_ROOT="$appify_NAME.appify/Contents/MacOS"
appify_INFO="$appify_NAME.appify/Contents/Info.plist"


# Create the bundle
if [[ -a "$appify_NAME.appify" ]]; then
echo "$PWD/$appify_NAME.appify already exists :(" 1>&2
exit 1
fi
mkdir -p "$appify_ROOT"

mkdir -p "$ROOT"

if [ -f "$FILE" ]; then
cp "$FILE" "$ROOT/$NAME"
echo "Copied $ROOT/$NAME" 1>&2
# Copy the source into the bundle as the CFBundleExecutable
if [ -f "$appify_SRC" ]; then
cp "$appify_SRC" "$appify_ROOT/$appify_FILE"
echo "Copied $appify_ROOT/$appify_FILE" 1>&2

else
touch "$ROOT/$NAME"
echo "Created blank $ROOT/$NAME" 1>&2
# Create a new blank CFBundleExecutable
cat <<-EOF > "$appify_ROOT/$appify_FILE"
#!/usr/bin/env bash
echo "This ('\$0') is a blank appified script." 1>&2
exit 1
EOF
echo "Created blank '$appify_ROOT/$appify_FILE' be sure to edit this file to make it do things and stuff" 1>&2
fi
chmod +x "$appify_ROOT/$appify_FILE"


# Create the Info.plist
cat <<-EOF > "$appify_INFO"
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>CFBundlePackageType</key><string>APPL</string><key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>CFBundleName</key> <string>$appify_NAME</string>
<key>CFBundleExecutable</key> <string>$appify_FILE</string>
<key>CFBundleIdentifier</key> <string>appified.$USER.$appify_FILE</string>
<key>CFBundleVersion</key> <string>0.1</string>
<key>CFBundleGetInfoString</key> <string>0.1 appified by $USER at `date`</string>
<key>CFBundleShortVersionString</key> <string>0.1</string>
</dict></plist>
EOF


# Appify!
if [[ -a "$appify_NAME.app" ]]; then
echo "$PWD/$appify_NAME.app already exists :(" 1>&2
exit 1
fi
mv "$appify_NAME.appify" "$appify_NAME.app"

chmod +x "$ROOT/$NAME"

echo "$PWD/$NAME.app"
# Success!
echo "Be sure to customize your $appify_INFO" 1>&2
echo "$PWD/$appify_NAME.app"

0 comments on commit d843430

Please sign in to comment.