npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tiapp-composer

v1.1.1

Published

Define dynamic tiapp.xml files with the power of template strings

Downloads

17

Readme

tiapp-composer

A Titanium plugin that enables the definition of a template file for the tiapp.xml of your project. It now supports the app/config.json file too!

NOTE: this script works only as a global plugin, since it has to modify tiapp.xml and config.json before the Titanium CLI parses them.

Installation

npm i -g tiapp-composer

Done!

Usage

The plugin will search for a config (tiapp-cfg.json) and a template file (tiapp.tpl) in your current working directory whenever you launch the titanium build and titanium clean commands. If it doesn't find the config file, it will give a warning and skip to the rest of the command. Once you define the config, however, you have to write a template, or the plugin will simply write an empty tiapp.xml.

tiapp.tpl and tiapp-cfg.json

The tiapp.tpl is an exact copy of a tiapp.xml. The only difference is that it will be treated as an ES6 template literal, so you can define custom variables:

<?xml version="1.0" encoding="UTF-8"?><ti:app xmlns:ti="http://ti.appcelerator.org">
	<id>${app.id}</id>
	<name>Tiapp Composer Test</name>
	<version>{$app.version}</version>
	<publisher>not specified</publisher>
	<url>caffeina.com</url>

	[...]

	<ios>
		<enable-launch-screen-storyboard>true</enable-launch-screen-storyboard>
		<use-app-thinning>true</use-app-thinning>
		<plist>
			<dict>

				[...]

				<key>LSApplicationQueriesSchemes</key>
				<array>
					${app.ios.querySchemes}
				</array>
				<key>NSAppTransportSecurity</key>
				<dict>
				<key>NSAllowsArbitraryLoads</key>
				<${app.ios.allowArbitraryLoads}/>

				[...]

			</dict>
		</plist>
	</ios>
	<android xmlns:android="http://schemas.android.com/apk/res/android">
	</android>

	[...]

	<sdk-version>${app.sdkVersion}</sdk-version>
<plugins><plugin version="1.0">ti.alloy</plugin>
</plugins>
</ti:app>

and the corresponding tiapp-cfg.json would be:

{
	"development": {
		"app": {
			"id": "com.myapp.title.test",
			"version": "6.6.6",
			"sdkVersion": "7.0.0.CUSTOMBUILD",
			"ios": {
				"querySchemes": "
				<string>testscheme</string>
				",
				"allowArbitraryLoads": "true"
			}
		}
	},
	"production": {
		"app": {
			"id": "com.myapp.title",
			"version": "6.6.0",
			"sdkVersion": "7.0.0.GA",
			"ios": {
				"querySchemes": "
				<string>twitter</string>
				<string>fb</string>
				",
				"allowArbitraryLoads": "false"
			}
		}
	}
}

As you can see, you can replace entire sections of the tiapp with a custom string. Hell, you could even put the whole tiapp.xml in the config as an attribute. I'm not judging you.

config.tpl and config-cfg.json

You can write a template and configuration for your config.json file too, in the same manner as above. Check out an example template and configuration

--tiappenv

You can use the --tiappenv flag in your titanium build or titanium clean command, with one of the top-level attribute names you defined:

ti build --platform android --target device --device-id all --tiappenv development

Running tiapp-composer...
[INFO]  tiapp-composer: Successfully wrote tiapp.xml

If you use a name you haven't defined in your config, the plugin will not write the tiapp.xml file:

ti build --platform android --target device --device-id all --tiappenv ayylmao

Running tiapp-composer...
[WARN]  tiapp-composer: Couldn't find the environment "ayylmao" in the tiapp-cfg.json file.
[WARN]  tiapp-composer Skipping tiapp.xml composing.

If you don't add the --tiappenv flag to your command, the plugin will default to the name development:

ti build --platform android --target device --device-id all

Running tiapp-composer...
[WARN]  tiapp-composer: --tiappenv flag not set, defaulting to "development"
[INFO]  tiapp-composer: Successfully wrote tiapp.xml

Tips

  • If you use TiNy (and you should, it's a real time saver), you can write a custom tn.json file and add some recipes with different --tiappenv flags:
tn project save testdroid --platform android --target device --device-id all --tiappenv mytestenv
tn project save proddroid --platform android --target device --device-id all --tiappenv myprodenv
  • If you use Git in your project (and if you are reading this, that's probably the case), you should append /tiapp.xml to your .gitignore file, since it will be overwritten at each build command. The plugin will even give you a warning if you don't do so.

But why, though?

The reason behind this contraption is that I had to switch between different tiapp settings in one of my projects, depending on the type of build i had deploy (test, enterprise, production...). Initially I would keep several branches with different tiapp files, but that approach was time and space consuming, and prone to errors. After trying other solutions, and with the pressing need to adopt CI in my projects, I decided to write my own plugin.