• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Codestrong 2012 breakout session   exploring the new titanium command line interface (cli)
 

Codestrong 2012 breakout session exploring the new titanium command line interface (cli)

on

  • 1,064 views

 

Statistics

Views

Total Views
1,064
Views on SlideShare
1,064
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Just like ti studio

Codestrong 2012 breakout session   exploring the new titanium command line interface (cli) Codestrong 2012 breakout session exploring the new titanium command line interface (cli) Presentation Transcript

  • Exploring The New Titanium Command Line Interface Chris Barber Sr. Platform Lead Appcelerator @cb1kenobi cbarber@appcelerator.com
  • About Me • Chris Barber • JavaScript Team Lead • Mobile Web, CLI • @cb1kenobi
  • Why Create a New CLI?If it ain’t broke, don’t fix it
  • Old School • Python 2.7.x • Poorly documented • Difficult to maintain • Inconsistent arguments • Rigid plugin system
  • 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
  • Appc Node.js • JavaScript! • MIT License • Small size • No native dependencies • Package manager (npm) • Tons of great community modules
  • Getting StartedInstalling the Titanium CLI
  • First Things First • Node.js • 0.8 or newer • NPM
  • Installation npm install -g titanium Note: may need to run as npm sudo
  • Touring the CLIBuilt-in Commands
  • Running The CLI chris@yojimbo:~$ titanium Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Usage: titanium <command> [options] Commands: config get and set config options help displays this help screen info display development environment information login logs into the Appcelerator network logout logs out of the Appcelerator network module manages installed Titanium Modules plugin manages installed Titanium Plugins sdk manages installed Titanium SDKs setup run the setup wizard status 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, --help displays help --prompt, --no-prompt prompt for missing options [default: true] -q, --quiet suppress all output -v, --version displays the current version
  • Help!titanium <cmd> -h chris@yojimbo:~$ titanium help config Titanium Command-Line Interface, version 3.0.7titanium <cmd> --help Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.titanium help <cmd> Usage: titanium config [--remove] [--output <value>] [<key>] [<value>] Gets and sets config options. If no key is specified, then all key/values are returned. The config file is located at: /Users/chris/.titanium/config.json Config Arguments: <key> the key to get or set <value> the value to set the specified key Config Flags: -r, --remove remove the specified config key and all its descendants Config Options: -o, --output <value> 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, --help displays help --prompt, --no-prompt prompt for missing options [default: true] -q, --quiet suppress all output -v, --version displays the current version
  • Setup WizardBasic Setuptitanium setupAdvanced Setup • Initializes the CLI configurationtitanium setup -a chris@yojimbo:~$ titanium setup Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Enter ctrl-c at any time to quit What is your name? (this is used as the default for the "author" field in the tiapp.xml or module manifest 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
  • Manual ConfigurationGet All Valuestitanium configGet All User.* • Get and set config settingsSettingstitanium config userSet Android SDK Path chris@yojimbo:~$ titanium configtitanium config android.ndkPath = "/opt/android-ndk" android.sdkPath android.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"
  • AuthenticationLogging In chris@yojimbo:~$ titanium logintitanium login Titanium Command-Line Interface, version 3.0.7 <username> Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Am I Logged In? Username: (cbarber@appcelerator.com)titanium status Password:Logging out Logged in successfullytitanium logout chris@yojimbo:~$ titanium status Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. You are currently logged in as cbarber@appcelerator.com chris@yojimbo:~$ titanium logout Titanium Command-Line Interface, version 3.0.7 Copyright (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
  • System Info chris@yojimbo:~$ titanium infoIncludes: Titanium Command-Line Interface, version 3.0.7• OS info Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Operating System• node.js & npm Name 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.63 simulators• iOS provisioning Xcode 4.4.1 (build 4F1003) Install Location = /Applications/Xcode44.app/Contents/Developer profiles & iOS SDKs iOS Simulators = 5.1 = 5.0, 5.1 keychains 4.5 (build 4G182) Install Location = /Applications/Xcode45.app/Contents/Developer• Titanium SDKs iOS 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 = installed Development iOS Provisioning ProfilesGet All Info My Provisioning Profile UUID = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXtitanium info App 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 os System.keychain = /Library/Keychains/System.keychain Titanium SDKs 2.1.3.GAiOS Info Only Install 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 = unknown Android Platforms android-8Android & Node.js Name API Level = Android 2.2 =8Info Only Revision Skins =3 = HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854titanium info -t ABIs Path = armeabi = /opt/android-sdk/platforms/android-8android,nodejs Android Add-ons Google Inc.:Google APIs:8 Name = Google APIs Vendor = Google Inc.Output as JSON Revision Description =2 = Android + Google APIstitanium info -o json Skins 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)
  • Modules & PluginsGet Installed Modules chris@yojimbo:~$ titanium module Titanium Command-Line Interface, version 3.0.7titanium module Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Global ModulesGet Installed ModulesIncluding a Project Android ti.cloudpushtitanium module 2.0.5 /Users/chris/Library/Application Support/Titanium/modules/android/ti.cloudpush/2.0.5 –project-dir 2.0.7 /Users/chris/Library/Application Support/Titanium/modules/android/ti.cloudpush/2.0.7 /path/to/project CommonJS ti.cloud 2.1.0 /Users/chris/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.1.0Get Installed Plugins 2.2.0 /Users/chris/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.2.0 2.3.0 /Users/chris/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.3.0titanium plugin 2.0.5 /Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.0.5 iPhoneOutput as JSON ti.jira 1.0 /Users/chris/Library/Application Support/Titanium/modules/iphone/ti.jira/1.0titanium plugin -o json Mobile Web ti.oldmodule 0.1 /Users/chris/Library/Application Support/Titanium/modules/mobileweb/ti.oldmodule/0.1 chris@yojimbo:~$ titanium plugin Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. User Path Plugins No project plugins found Global Plugins another_plugin 1.0 /Users/chris/Library/Application Support/Titanium/plugins/another_plugin/1.0 test_plugin 1.0 /Users/chris/Library/Application Support/Titanium/plugins/test_plugin/1.0 ti.alloy 1.0 /Users/chris/Library/Application Support/Titanium/plugins/ti.alloy/1.0
  • Wait!Where’s the create and build commands?
  • Downloading An SDKList Intalled SDKs chris@yojimbo:~$ titanium sdktitanium sdk Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.Install Latest 3.0titanium sdk install Installed SDKs: --branch 3_0_X 2.1.3.GA [default] /Users/chris/Library/ApplicationSupport/Titanium/mobilesdk/osx/2.1.3.GA --default 2.1.2.GA /Users/chris/Library/ApplicationSupport/Titanium/mobilesdk/osx/2.1.2.GA 2.1.0.GA /Users/chris/Library/ApplicationSupport/Titanium/mobilesdk/osx/2.1.0.GAInstall Latest Stable 2.0.2.GA /Users/chris/Library/ApplicationSupport/Titanium/mobilesdk/osx/2.0.2.GAtitanium sdk install chris@yojimbo:~$ titanium sdk install --branch 3_0_X --defaultInstall Latest Stable & Titanium Command-Line Interface, version 3.0.7Set as Default SDK Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.titanium sdk install --default Downloading http://builds.appcelerator.com.s3.amazonaws.com/mobile/3_0_X/mobilesdk- 3.0.0.v20121018214614-osx.zipInstall Bleeding Edge 100% [=================================================================] 0.0stitanium sdk install --branch master Extracting SDK... Saving SDK 3.0.0.v20121018214614 as the default. Titanium SDK 3.0.0.v20121018214614 successfully installed!
  • New Commands! chris@yojimbo:~$ titanium Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Usage: titanium <command> [options] Commands: build builds a project clean removes previous build directories config get and set config options create creates a new mobile application or module help displays this help screen info display development environment information login logs into the Appcelerator network logout logs out of the Appcelerator network module manages installed Titanium Modules plugin manages installed Titanium Plugins project get and set tiapp.xml settings sdk manages installed Titanium SDKs setup run the setup wizard status 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, --help displays help --prompt, --no-prompt prompt for missing options [default: true] -q, --quiet suppress all output -v, --version displays the current version
  • SDK Commandscreate, project, build, clean
  • Creating a ProjectCreate a Project chris@yojimbo:~$ titanium create Titanium Command-Line Interface, version 3.0.7titanium create Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Target platforms: (android,ios,ipad,iphone,mobileweb)Create Project With App ID: com.appcelerator.myappAll Arguments Project name: myapptitanium sdk create [INFO] Creating Titanium Mobile application project [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default => --id com.appc.myapp /Users/chris/myapp --name myapp [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources => /Users/chris/myapp/Resources --platforms [DEBUG] Copying /Users/chris/Library/Applicationandroid,iphone,ipad, Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android => /Users/chris/myapp/Resources/android [DEBUG] Copying /Users/chris/Library/Applicationmobileweb Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images => --workspace-dir /Users/chris/myapp/Resources/android/images [DEBUG] Copying /Users/chris/Library/Application /path/to/workspace Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-long-land-hdpi => /Users/chris/myapp/Resources/android/images/res-long-land-hdpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-long-land-ldpi => /Users/chris/myapp/Resources/android/images/res-long-land-ldpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-long-port-hdpi => /Users/chris/myapp/Resources/android/images/res-long-port-hdpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-long-port-ldpi => /Users/chris/myapp/Resources/android/images/res-long-port-ldpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-notlong-land-hdpi => /Users/chris/myapp/Resources/android/images/res-notlong-land-hdpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-notlong-land-ldpi => /Users/chris/myapp/Resources/android/images/res-notlong-land-ldpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-notlong-land-mdpi => /Users/chris/myapp/Resources/android/images/res-notlong-land-mdpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-notlong-port-hdpi => /Users/chris/myapp/Resources/android/images/res-notlong-port-hdpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-notlong-port-ldpi => /Users/chris/myapp/Resources/android/images/res-notlong-port-ldpi [DEBUG] Copying /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.v20121018214614/android/templates/app/default/Resources/android/images/res-notlong-port-mdpi => /Users/chris/myapp/Resources/android/images/res-notlong-port-mdpi [INFO] Project myapp created successfully in 32ms
  • Getting Project InfoBasic Infotitanium projectCopy Platform • Tool for interacting with the tiapp.xmlResource Filestitanium project --deployment-targets chris@yojimbo:~/myapp$ titanium project android,ios,mobileweb Titanium Command-Line Interface, version 3.0.7 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. Deployment Targets: android = true ipad = false iphone = true mobileweb = true Project Properties: sdk-version = 3.0.0 id = com.appcelerator.myapp name = myapp version = 1.0 publisher = not specified url = not specified description = not specified copyright = not specified icon = appicon.png analytics = true guid = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  • Building a ProjectPlatforms: chris@yojimbo:~/myapp$ titanium build --platform ios• iOS Titanium Command-Line Interface, version 3.0.6• Mobile Web Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved.• Android [DEBUG] No project level plugins to load [DEBUG] Loaded plugin hooks:Special Hooks: [DEBUG] /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.1.0/cli/hooks/plugins.js• Run in Simulator [DEBUG] /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.1.0/iphone/cli/hooks/install.js• Install on Device [DEBUG] /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.1.0/iphone/cli/hooks/package.js [DEBUG] /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.1.0/iphone/cli/hooks/run.js• Package for [INFO] Build type: development Distribution [DEBUG] Titanium iOS SDK directory: /Users/chris/Library/Application Support/Titanium/mobilesdk/osx/3.1.0/iphone [INFO] Building for target: simulator [INFO] Building using iOS SDK: 6.0 [INFO] Building for iOS Simulator: 6.0 [INFO] Building for device family: universal [DEBUG] Setting Xcode target to Debug [DEBUG] Setting Xcode build OS to iphonesimulator6.0 [DEBUG] Xcode installation: /Applications/Xcode45.app/Contents/Developer [DEBUG] iOS WWDR certificate: installed [INFO] Building for iOS 6.0; using 4.3 as minimum iOS version [DEBUG] Minimum iOS version: 4.3 [INFO] Debugging disabled [DEBUG] Building for the following architectures: armv7 armv7s i386 [DEBUG] Forcing rebuild: githash changed since last build [DEBUG] Was: a50c927 [DEBUG] Now: ab2b280 [INFO] Cleaning old build directory [DEBUG] Would be firing "compile" legacy plugin hook if it was supported [INFO] Building Info.plist [INFO] No Titanium Modules required, continuing [INFO] Performing full rebuild [INFO] Copying Xcode iOS files ...
  • Cleaning the ProjectNuke All PlatformBuild Directoriestitanium clean • Completely removes the platform specific buildNuke a SpecificPlatform’s Build directoriesDirectorytitanium clean –platform android chris@yojimbo:~/myapp$ titanium clean Titanium Command-Line Interface, version 3.0.6 Copyright (c) 2012, Appcelerator, Inc. All Rights Reserved. [INFO] Project cleaned successfully in 1ms
  • Extending the CLIPlugins, commands, and hooks
  • Plugins • Similar to Titanium Modules • Legacy plugin.py not supported today • CLI commands & hooks • Installed globally or in project directory • Enabled via the tiapp.xml <plugins>
  • Sample Command myplugin/1.0/cli/commands/magic.js exports.cliVersion = >=3.X; exports.desc = does magical things’; exports.config = function (logger, config, cli) { return { flags: { extra: { abbr: e, desc: adds more magic’ } } }; }; exports.validate = function (logger, config, cli) { // nothing to validate }; exports.run = function (logger, config, cli) { var s = doing magical stuff!; if (cli.argv.extra) { s = s.replace(/./g, function (c, i) { return i % 2 == 0 ? c.toUpperCase() : c.toLowerCase(); }); } logger.log(s); };
  • Sample Hook myplugin/1.0/cli/hooks/buildhook.js exports.cliVersion = >=3.X; exports.init = function (logger, config, cli) { cli.addHook(build.pre.compile, function (data, finished) { logger.log(modifying some code before build starts); finished(); }); cli.addHook(build.post.compile, { priority: 900, post: function (data, finished) { logger.log(packaging some extra files after the build); finished(); } }); cli.addHook(build.finalize, function (data, finished) { logger.log(cleaning up my mess); finished(); }); };
  • DemoKick the tires & light the fires
  • What’s Next?
  • // TODO: • More plugin hooks • Project exporting & migration tools • Better support for multiple Titanium SDKs • What would you like to see?
  • SummaryJust in case you were sleeping
  • The New CLI Rocks • Easy to install, easy to use • Fast as shit • Built-in documentation • Extensible plugin architecture • Consistent arguments • Argument prompting • Internationalization • Colors!
  • Get It Today! npm install -g titanium titanium sdk install --branch 3_0_X --default Note: may need to run npm as sudo
  • Chris Barber @cb1kenobicbarber@appcelerator.com