Exploring the Titanium CLI - Codestrong 2012

Embed Size (px)


I gave this presentation on Oct 23, 2012 at Appcelerator's annual Codestrong conference.

Text of Exploring the Titanium CLI - Codestrong 2012

  • 1.Exploring The New Titanium Command Line InterfaceChris Barber Sr. Platform Lead Appcelerator@cb1kenobi cbarber@appcelerator.com

2. Meet Chris Chris Barber JavaScript Team Lead Mobile Web, CLI @cb1kenobi 3. Why Create a New CLI? 4. Titanium 2.X CLI Python 2.7 Inconsistent Poorly documented Difficult to use Even more difficult to maintain 5. Project Creationchris@yojimbo:~$ python /Users/chris/Library/ApplicationSupport/Titanium/mobilesdk/osx/2.1.3.GA/project.pyUsage:project.py [iphone,android,mobileweb] [android_sdk] [--update-platforms]Options: -h, --helpshow this help message and exit -u, --update-platforms Initialize project for any missing platforms. Use this to add a platform to the project without overwriting tiapp.xml and app.js.chris@yojimbo:~$ python /Users/chris/Library/ApplicationSupport/Titanium/mobilesdk/osx/2.1.3.GA/project.py myapp com.mycompany.myapp . foo 6. Build iOS App chris@yojimbo:~$ python /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/builder.py builder.py [options] available commands:install install the app to itunes for testing on iphonesimulator build and run on the iphone simulatoradhoc build for adhoc distributiondistribute build final distribution bundlexcodebuild from within xcoderun build and run app from project folder 7. Build iOS App chris@yojimbo:~$ python /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/builder.py simulator [INFO] One moment, building ... Traceback (most recent call last): File "/Users/chris/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/builder.py", line 1594, in main(sys.argv) File "/Users/chris/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA/iphone/builder.py", line 608, in mainiphone_version = dequote(args[2].decode("utf-8")) IndexError: list index out of range builder.py simulator [ [ []]] 8. OK, We Need A New CLI 9. Building a New CLI Python 3? Node.js? Ruby? Java+Rhino? How comfortable are we with these technologies? Compatible license? What libraries are available? XML/JSON parsing Code minification Image resizing 10. Appc Node.js JavaScript! MIT License Small size No native dependencies Package manager (npm) Tons of great community modules 11. Getting StartedInstalling the Titanium CLI 12. First Things First Node.js 0.8 or newer NPM 13. Installation npm install -g titanium Note: may need to run as npm sudo 14. Touring the CLIBuilt-in Commands 15. Running The CLI chris@yojimbo:~$ titanium Titanium Command-Line Interface, version 3.0.10 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Usage: titanium [options] Commands:config get and set config optionshelp displays this help screeninfo display development environment informationlogin logs into the Appcelerator networklogout logs out of the Appcelerator networkmodule manages installed Titanium Modulesplugin manages installed Titanium Pluginssdkmanages installed Titanium SDKssetup run the setup wizardstatus displays session information Global Flags:--banner, --no-banner displays Titanium version banner [default: true]--colors, --no-colors use colors in the terminal [default: true]-h, --helpdisplays help--prompt, --no-prompt prompt for missing options [default: true]-q, --quietsuppress all output-v, --version displays the current version 16. Help!titanium -h chris@yojimbo:~$ titanium help configTitanium Command-Line Interface, version 3.0.10titanium --help Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.titanium help Usage: titanium config [--remove] [--output ] [] []Gets and sets config options. If no key is specified, then all key/values arereturned.The config file is located at: /Users/chris/.titanium/config.jsonConfig Arguments: the key to get or set the value to set the specified keyConfig Flags: -r, --remove remove the specified config key and all its descendantsConfig Options: -o, --output output format [report, json]Global Flags: --banner, --no-banner displays Titanium version banner [default: true] --colors, --no-colors use colors in the terminal [default: true] -h, --helpdisplays help --prompt, --no-prompt prompt for missing options [default: true] -q, --quietsuppress all output -v, --version displays the current version 17. Setup WizardBasic Setuptitanium setupAdvanced Setup Initializes the CLI configurationtitanium setup -achris@yojimbo:~$ titanium setupTitanium Command-Line Interface, version 3.0.10Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Enter ctrl-c at any time to quitWhat is your name? (this is used as the default for the "author" field in the tiapp.xml or modulemanifest file when creating new projects) (Chris Barber)What is your email address used for logging into the Appcelerator Network? (cbarber@appcelerator.com)What would you like as your default locale? (examples: "en", "de", "fr") (en-us)What Titanium SDK would you like to use by default? (2.1.3.GA)Path to your workspace where your projects should be created: (~/appc/workspace)Path to the Android SDK: (this is needed for building Android apps)Configuration saved 18. Manual ConfigurationGet All Valuestitanium configGet All User.* Get and set config settingsSettingstitanium config user chris@yojimbo:~$ titanium configSet Android SDK Pathtitanium configandroid.ndkPath = "/opt/android-ndk"android.sdkPathandroid.sdkPath = ""/path/to/sdk app.idprefix = "com.appcelerator" app.publisher = "Appcelerator" app.sdk= "2.1.3.GA" app.url = "" app.workspace = "~/appc/workspace" cli.colors = true cli.failOnWrongSDK = false cli.logLevel= "trace" cli.prompt= true cli.quiet = false ios.developerName = "Chris Barber" ios.distributionName = "Appcelerator, Inc." paths.commands= [] paths.hooks = [] paths.plugins = ["~/appc/ti.alloy"] user.email= "cbarber@appcelerator.com" user.locale = "en-us" user.name= "Chris Barber" 19. AuthenticationLogging Inchris@yojimbo:~$ titanium logintitanium loginTitanium Command-Line Interface, version 3.0.10Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Am I Logged In?titanium status Username: (cbarber@appcelerator.com)Password:Logging outtitanium logout Logged in successfullychris@yojimbo:~$ titanium statusTitanium Command-Line Interface, version 3.0.10Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.You are currently logged in as cbarber@appcelerator.comchris@yojimbo:~$ titanium logoutTitanium Command-Line Interface, version 3.0.10Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Logged out successfully Required for most commands Adds your app to my.appcelerator.com Username is your e-mail address 20. System Infochris@yojimbo:~$ titanium infoIncludes: Titanium Command-Line Interface, version 3.0.10 OS infoCopyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Operating System node.js & npmName Version = Mac OS X = 10.8.2 Xcode versions Memory = 16.0GB iOS SDKs &node.js node.js Version= v0.8.12 npm Version= 1.1.63simulators iOS provisioningXcode4.4.1 (build 4F1003) Install Location = /Applications/Xcode44.app/Contents/Developerprofiles & iOS SDKs iOS Simulators = 5.1 = 5.0, 5.1keychains 4.5 (build 4G182) Install Location = /Applications/Xcode45.app/Contents/Developer Titanium SDKsiOS SDKs iOS Simulators = 6.0 = 5.0, 5.1, 6.0 Android SDKs, iOS Certificates Development= Chris Barber (XXXXXXXXXX)addons, and AVDs Distribution = Appcelerator, Inc. Apple WWDR= installedDevelopment iOS Provisioning ProfilesGet All InfoMy Provisioning Profile UUID = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXtitanium infoApp Prefix App Id= XXXXXXXXXX= com.appcelerator.*iOS Keychains System Default = System DefaultOS Info Only login.keychain= /Users/chris/Library/Keychains/login.keychain Microsoft_Intermediate_Certificates= /Users/chris/Library/Keychains/Microsoft_Intermediate_Certificatestitanium info -t osSystem.keychain = /Library/Keychains/System.keychainTitanium SDKs2.1.3.GAiOS Info OnlyInstall Location Platforms = /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/2.1.3.GA= android, iphone, mobileweb git Hash= unknowntitanium info -t ios git Timestamp= unknownAndroid Platformsandroid-8Android & Node.jsName API Level = Android 2.2=8Info OnlyRevision Skins=3= HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854titanium info -t ABIs Path= armeabi= /opt/android-sdk/platforms/android-8android,nodejsAndroid Add-onsGoogle Inc.:Google APIs:8 Name= Google APIs Vendor= Google Inc.Output as JSON Revision Description=2 = Android + Google APIstitanium info -o jsonSkins ABIs= WVGA854, WQVGA400, HVGA, WQVGA432, WVGA800 (default), QVGA= armeabi Path = /opt/android-sdk/add-ons/addon-google_apis-google-10 Based On= Android 2.2 (API level 8) Libraries = com.google.android.maps: API for Google Maps (maps.jar) 21. Modules & PluginsGet Installed Modules chris@yojimbo:~$ titanium moduletitanium moduleTitanium Command-Line Interface, version 3.0.10Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Get Installed ModulesIncluding a Projecttitanium module Global Modulesproject-dir/path/to/projectAndroid ti.cloudpush 2.0.7 /Users/chris/Library/Application Support/Titanium/modules/android/ti.cloudpush/2.0.7CommonJS ti.cloudcommonjs/ti.cloud/2.2.0 2.3.0 /Users/chris/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.3.0 2.0.5 /Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.0.5iPhone ti.jira 1.0 /Users/chris/Library/Application Support/Titanium/modules/iphone/ti.jira/1.0Mobile Web ti.oldmodule 0.1 /Users/chris/Library/Application Support/Titanium/modules/mobileweb/ti.oldmodule/0.1 22. Modules & PluginsGet Installed Pluginstitanium pluginOutput as JSONtitanium plugin chris@yojimbo:~$ titanium plugin-o json Titanium Command-Line Interface, version 3.0.10Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.User Path PluginsNo project plugins foundGlobal Pluginsanother_plugin 1.0 /Users/chris/Library/Application Support/Titanium/plugins/another_plugin/1.0test_plugin 1.0 /Users/