Skip to content

Loading…

Fixes tiapp.xml to allow building for android right after running `titanium-backbone new` #6

Merged
merged 1 commit into from

2 participants

@svallory

Adds the parameter -u (--puburl) to set the publisher url. Changes the
way app id is generated to use the reverse domain + app name. Adds an
app icon.png for android and iPhone.

I really think we should have a shorter name :)

@svallory svallory fixes tiapp.xml to allow building for android right after running new
Adds the parameter er (--puburl) to set the publisher url. Changes the
way app id is generated to use the reverse domain + app name. Adds an
app icon.png for android and iPhone.
ac0a3ac
@trabianmatt trabianmatt merged commit 797e872 into trabian:master
@trabianmatt
Trabian member

@svallory, Thanks for the pull request -- I particularly like the appicon.

One thing I noticed while merging this is that I hadn't checked the KitchenSink against Titanium 2.0. I ended up needing to update a few sizes (setting ContentBlock height to Ti.UI.SIZE and table row heights to 44).

Note that we haven't done anything with Android within this app yet. On the production app that we're extracting this from we had two separate packaging scripts. They both included a base set of functionality but one included iOS-specific code (especially styles) and the other included Android-specific code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 29, 2012
  1. @svallory

    fixes tiapp.xml to allow building for android right after running new

    svallory committed
    Adds the parameter er (--puburl) to set the publisher url. Changes the
    way app id is generated to use the reverse domain + app name. Adds an
    app icon.png for android and iPhone.
View
4 lib/command/new.coffee
@@ -20,8 +20,9 @@ module.exports =
program
.version(pkg.version)
.usage('new <app-name>')
- .option('-i, --id <id>', 'App ID (defaults to dasherized version of <app-name>)')
+ .option('-i, --id <id>', 'App ID (defaults to reverse publisher url (-url param) followed by dasherized version of <app-name>. eg: com.example.my-app)')
.option('-d, --dir <dir>', 'Directory (defaults to ./<id>)')
+ .option('-u, --puburl <puburl>', 'The publisher URL (defaults to http://www.example.com)')
program.on '--help', ->
console.log examples
@@ -36,3 +37,4 @@ module.exports =
name: program.args[0]
id: program.id
dir: program.dir
+ puburl: program.puburl
View
BIN lib/generator/_template/Resources/android/appicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN lib/generator/_template/Resources/iphone/appicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
23 lib/generator/index.coffee
@@ -6,6 +6,17 @@ wrench = require 'wrench'
dasherize = (str) ->
str.toLowerCase().replace /[_\s]/g, '-'
+urlToPackage = (url) ->
+ url
+ .replace(/http[s]?:\/\/(www\.)?/, '')
+ .replace(/(www\.)?/, '')
+ .split('.')
+ .reverse()
+ .join '.'
+
+generateAppId = (options) ->
+ urlToPackage(options.puburl) + '.' + dasherize options.name
+
buildPackage = (options) ->
name: options.id
version: '0.0.1'
@@ -24,6 +35,7 @@ buildPackage = (options) ->
mobile:
id: options.id
name: options.name
+ puburl: options.puburl
engine:
node: ">= 0.6"
@@ -31,9 +43,14 @@ module.exports =
app: (options) ->
- options.id or= dasherize options.name
+ options.puburl or= "http://www.example.com"
+
+ options.id or= generateAppId options
- options.dir or= "./#{options.id}"
+ options.dir or= "./#{dasherize options.name}"
+
+ if options.puburl.substr(0,4) != 'http'
+ options.puburl = 'http://' + options.puburl
path.exists options.dir, (exists) ->
@@ -60,7 +77,7 @@ module.exports =
else
wrench.copyDirRecursive "#{__dirname}/_template", options.dir, ->
-
+
writeFile 'package.json', (pd.json JSON.stringify buildPackage(options)), ->
console.log """
View
1 lib/util/bootstrap.coffee
@@ -19,6 +19,7 @@ createTiapp = (options) ->
guid: uuid.v4()
id: options.id
name: options.name
+ url: options.puburl
jade.renderFile "#{__dirname}/tiapp.jade", options, (err, str) ->
throw err if err
View
2 lib/util/tiapp.jade
@@ -12,7 +12,7 @@ ti:app(xmlns:ti="http://ti.appcelerator.org")
name= name
version 0.0.1
publisher [publisher]
- url [url]
+ url= url
description [description]
copyright [copyright]
icon appicon.png
Something went wrong with that request. Please try again.