Titanium JIRA Archive
Alloy (ALOY)

[ALOY-783] Alloy: config.json environment-specific global values are ignored, always returning the env:development value

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2013-08-14T23:52:21.000+0000
Affected Version/sAlloy 1.2.0, 2013 Sprint 17
Fix Version/sAlloy 1.2.0, 2013 Sprint 17
Componentsn/a
Labelsqe-3.1.2, qe-testadded, regression
ReporterFederico Casali
AssigneeTony Lukasavage
Created2013-08-14T07:03:36.000+0000
Updated2013-08-15T22:56:04.000+0000

Description

Problem description

Environment specific global values are not respected, the value returned is always the one relative to the 'env:development'

Steps to reproduce

1. Run the sample code

config.json

{
	"global": {
		"key": "defaultValue",
		"anotherKey": 12345
	},
	"env:development": {
		"environment": "development"
	},
	"env:test": {
		"environment": "test"
	},
	"env:production": {
		"environment": "production"
	},
	"os:ios": {
		"key": "iosValue"
	},
	"os:android": {
		"key": "androidValue"
	},
	"dependencies": {}
}

index.xml

<Alloy>
    <Window id="win" backgroundColor="white" exitOnClose="true" fullscreen="false" title="ScrollView Demo">
        <View id="view" backgroundColor="#336699">
        	<Label id='label1' top='20'>platform key: </Label>
        	<Label id='label2' top='80'>global key: </Label>
        	<Label id='label3' top='140'>environment: </Label>
        </View>
    </Window>
</Alloy>

index.js

// Alloy.Globals.someGlobalObject = { key: 'value' };

$.label1.text =  $.label1.text + ' ' + Alloy.CFG.key;
$.label2.text =  $.label2.text + ' ' + Alloy.CFG.anotherKey;
$.label3.text =  $.label3.text + ' ' + Alloy.CFG.environment;


if ((Alloy.isHandheld) && (OS_IOS)){
	alert('iphone handheld!')
}
else if ((Alloy.isHandheld) && (OS_ANDROID)){
	alert('android handheld')
}
else if ((Alloy.isTablet)&&(OS_IOS)){
	alert('ipad tablet!')
}
else if ((Alloy.isTablet)&&(OS_ANDROID)){
	alert('android tablet')
}
else if (OS_MOBILEWEB){
	alert('mobileweb!')
}
else {
	alert("I don't know!'")
}

$.win.open();

2. Build for packaging (tested on Android) 3. Install the package on device and run the app Result: 'environment: development' label is displayed Expected result: "environment: production" label should be displayed.

Note

This is not reproducible on Alloy 1.1.3, so is a regression.

Comments

  1. Tony Lukasavage 2013-08-14

    Notes so far: I am able to see this problem even on 1.1.3, doing both test and production builds, they always show up as development. I've also tried various versions of the CLI (3.1.0-3.2.0) and the TiSDK. All behave the same way for android builds. In perusing the CLI android build command code, it appears that the deploy type is never actually set. Unfortunately, due to the way the CLI is structured, this appears to be a change that needs to be made in the TiSDK, not the CLI node module. https://github.com/appcelerator/titanium_mobile/blob/master/android/cli/commands/_build.js If you look in the above file you'll see that "deploy-type" is not implemented as an option (it's commented out). In addition, when specifying a device build, you'd use the "--target, -T" option, which does not modify the deploy type in anyway. In fact, as Federico confirmed with the packaging test, no where in the _build.js file does it appear that the deploy type is taken into account. The "deployTypes" defined at the top of the file appear to be unused. This appears to be a TIMOB CLI issue, but I will need to confirm with [~fcasali].
  2. Tony Lukasavage 2013-08-14

    PR: https://github.com/appcelerator/alloy/pull/221 [~fcasali] can you test this against the test app you laid out in the ticket here and make sure that it behaves as expected for all builds? Please install alloy with the following command:
       sudo npm install -g git://github.com/appcelerator/alloy.git#1_2_X
       
  3. Tony Lukasavage 2013-08-14

    Re-opening to address issue with CFG.js not updating when deploy type changes. Also is affected by TIMOB-14884.
  4. Tony Lukasavage 2013-08-14

    PR: https://github.com/appcelerator/alloy/pull/222 [~fcasali] try all the tests again. All mentioned issues should now pass when installing from the 1_2_X branch as mentioned above.
       sudo npm install -g git://github.com/appcelerator/alloy.git#1_2_X
       
  5. Tony Lukasavage 2013-08-14

    Confirmed as resolved. Pushed alloy 1.2.0-beta as a result.
  6. Federico Casali 2013-08-15

    Verified fixed. Environment specific global variables are returned correctly depending on the deploy. Titanium SDK 3.1.2.v20130814124556 Alloy 1.2.0-beta Appcelerator Studio 3.1.2.201308091728 CLI 3.1.2-alpha Node 0.10.13 Android, iOS and MobileWeb Closing.

JSON Source