{ "id": "124581", "key": "TIMOB-16153", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15817", "description": "2014 Sprint 01", "name": "2014 Sprint 01", "archived": true, "released": true, "releaseDate": "2014-01-17" }, { "id": "15819", "description": "2014 Sprint 01 Core", "name": "2014 Sprint 01 Core", "archived": true, "released": true, "releaseDate": "2014-01-17" }, { "id": "15856", "description": "Release 3.2.1", "name": "Release 3.2.1", "archived": false, "released": true, "releaseDate": "2014-02-10" }, { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-01-17T01:36:41.000+0000", "created": "2014-01-09T03:14:44.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "qe-testadded" ], "versions": [ { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [ { "id": "34367", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "124968", "key": "TIMOB-16231", "fields": { "summary": "LiveView needs to be updated to use the new Titanium CLI 3.2.1 hook API", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "34542", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "125216", "key": "TIMOB-16289", "fields": { "summary": "CLI 3.2.1: Unable to build app using SDK 3.1.3 GA build", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "34958", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "126046", "key": "TIMOB-16417", "fields": { "summary": "CLI: Build - If you have 3.2.0 CLI with 3.2.1 SDK selected in CLI and in tiapp.xml, then \"Invalid platform \"undefined\"\" message is returned ", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "41110", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "136540", "key": "TIMOB-17689", "fields": { "summary": "CLI: Hook system shows warning 'bad plugin hook that failed to load' at build time", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "updated": "2014-09-15T14:48:52.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "13103", "name": "CLI", "description": "Node-based command line interface" } ], "description": "The hook system has a big issue where the \"pre\" function hook signature differs from the \"post\". This is a bug. They should be the same and the \"post\" is correct, the \"pre\" is not.\r\n\r\nBoth the \"pre\" and \"post\" should have the first argument be a possible error object. The second arg should be the \"data\" object.\r\n\r\nThe hook system only processes errors for post hooks, not pre hooks. So, by fixing the \"pre\" function signature, fixing up error handling to prevent the hook from finishing should be easy.\r\n\r\nThis shouldn't impact plugins or the SDK with these changes since \"pre\" hooks are used often.\r\n\r\nThe fire hook callback (the calls from the SDK) current emit 3 args, though only 2 make sense. We should fix this, but this will break 3.2.0. This can be fixed by checking the callback function length.\r\n\r\nLastly, the if a pre or post function hook should fail, then all places in the SDK that fire a hook should look for errors and gracefully abort the operation.", "attachment": [ { "id": "45270", "filename": "batman.zip", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2014-01-21T21:02:19.000+0000", "size": 2731, "mimeType": "application/zip" } ], "flagged": false, "summary": "CLI: Hook system has wrong callback signatures and poor error handling", "creator": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "environment": null, "comment": { "comments": [ { "id": "287639", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "Titanium CLI master pull request: https://github.com/appcelerator/titanium/pull/94\r\nTitanium CLI 3.2.x pull request: https://github.com/appcelerator/titanium/pull/100\r\n\r\nTitanium SDK master pull request: https://github.com/appcelerator/titanium_mobile/pull/5206\r\nTitanium SDK 3.2.x pull request: https://github.com/appcelerator/titanium_mobile/pull/5207\r\n\r\nTo test:\r\n1. create an app\r\n2. unzip the attached batman.zip into you project dir\r\n3. edit tiapp.xml and add enable the plugin:\r\n\r\n{code}\r\n\r\n batman\r\n\r\n{code}\r\n\r\n4. build an app for ios and android\r\n5. watch the output for the various pre and post log messages\r\n\r\nTo test the error handling:\r\n\r\n1. edit the plugin: plugins/batman/hooks/robin.js\r\n2. locate the \"build.android.javac\" hook listener\r\n3. change the \"pre\" function's next(null, data); to next(true, data);\r\n4. build an android app\r\n5. observe that the hook has returned an error and caused the build to fail", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2014-01-10T15:36:20.000+0000", "updated": "2014-01-17T21:52:48.000+0000" }, { "id": "287651", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I remember talking about this, or something very similar, WRT the Soasta hook. We should make sure that this change causes no problems with the newly rewritten Soasta hook, as handled in TIMOB-15914.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-10T16:42:54.000+0000", "updated": "2014-01-10T16:42:54.000+0000" }, { "id": "288405", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~tlukasavage] I just checked and the Soasta hook looks to be unaffected by these changes.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2014-01-16T02:54:09.000+0000", "updated": "2014-01-16T02:54:09.000+0000" }, { "id": "288685", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "Here's the PRs for Tizen:\n\nhttps://github.com/appcelerator/titanium_mobile_tizen/pull/5\nhttps://github.com/appcelerator/titanium_mobile_tizen/pull/6", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2014-01-17T22:50:52.000+0000", "updated": "2014-01-17T22:50:52.000+0000" }, { "id": "288731", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "Found a small regression in the iOS build when building for iOS device.\n\nhttps://github.com/appcelerator/titanium_mobile/pull/5236\nhttps://github.com/appcelerator/titanium_mobile/pull/5237", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2014-01-18T06:20:38.000+0000", "updated": "2014-01-18T06:20:38.000+0000" }, { "id": "288914", "author": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested following test steps in [~cbarber] comment and verified the \n{code}\n[FUNCTION-POST-HOOK] \n[FUNCTION-PRE-HOOK] \n{code}\nare the same for iOS and Android in the console,\nhowever Tizen fails \n{code}\nTypeError: Object 6 has no method 'replace'\n at /Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/tizen/cli/commands/_build.js:851:79\n at Array.forEach (native)\n at build.assembleTitaniumJS (/Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/tizen/cli/commands/_build.js:847:22)\n at /Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/node_modules/async/lib/async.js:508:21\n at /Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/node_modules/async/lib/async.js:224:13\n at /Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/node_modules/async/lib/async.js:108:13\n at Array.forEach (native)\n at _each (/Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/node_modules/async/lib/async.js:32:24)\n at async.each (/Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/node_modules/async/lib/async.js:107:9)\n at _asyncMap (/Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.2.1.v20140117222448/node_modules/async/lib/async.js:223:9)\n\n{code}\n\n├── acs@1.0.11\n├── alloy@1.3.1-beta2\n├── npm@1.3.2\n├── titanium@3.2.1\n└── titanium-code-processor@1.1.0\nnpm -g ls titanium: /usr/local/lib\n└── titanium@3.2.1 (git://github.com/appcelerator/titanium.git#93286e7b263a968cb362cf4e2a367a9b31f4ccb3)\n\n\n", "updateAuthor": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-20T22:59:38.000+0000", "updated": "2014-01-20T22:59:38.000+0000" }, { "id": "289140", "author": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested and verified the fix, using the corrected batman.zip\r\n\r\nAppcelerator Studio, build: 3.2.1.201401201818\r\nTitanium SDK, build: 3.2.1.v20140121105646\r\n├── acs@1.0.11\r\n├── alloy@1.3.1-beta2\r\n├── npm@1.3.2\r\n├── titanium@3.2.1\r\n└── titanium-code-processor@1.1.0\r\nnpm -g ls titanium: /usr/local/lib\r\n└── titanium@3.2.1 (git://github.com/appcelerator/titanium.git#93286e7b263a968cb362cf4e2a367a9b31f4ccb3)\r\n\r\nNo errors", "updateAuthor": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-21T22:43:50.000+0000", "updated": "2014-01-21T22:44:44.000+0000" }, { "id": "291254", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "To recap, Titanium CLI 3.2.0 and older, you would do:\n\n{code}\nexports.init = function (logger, config, cli, appc) {\n cli.on('build.android.copyResource', {\n pre: function (data, next) {\n logger.log('[FUNCTION-PRE-HOOK] build.android.copyResource'.magenta);\n next(data); // no error param :(\n },\n post: function (data, next) {\n logger.log('[FUNCTION-POST-HOOK] build.android.copyResource'.magenta);\n next(null, data);\n }\n });\n};\n{code}\n\nStarting in Titanium CLI 3.2.1 and newer, the \"pre\" callback expects the callback to pass back an error argument:\n\n{code}\nexports.init = function (logger, config, cli, appc) {\n cli.on('build.android.copyResource', {\n pre: function (data, next) {\n logger.log('[FUNCTION-PRE-HOOK] build.android.copyResource'.magenta);\n if ((new Date).getMonth() == 1) {\n // stop the build\n next(new Error(\"We don't work in February!\"));\n } else {\n next(null, data);\n }\n },\n post: function (data, next) {\n logger.log('[FUNCTION-POST-HOOK] build.android.copyResource'.magenta);\n next(null, data);\n }\n });\n};\n{code}\n\nTo support all CLI versions, then you'd have to check the version number like this:\n\n{code}\nexports.init = function (logger, config, cli, appc) {\n cli.on('build.android.copyResource', {\n pre: function (data, next) {\n logger.log('[FUNCTION-PRE-HOOK] build.android.copyResource'.magenta);\n if ((new Date).getMonth() == 1) {\n // stop the build\n if (appc.version.gte(appc.version.format(cli.version, 0, 3, true), '3.2.1')) {\n next(new Error(\"We don't work in February!\"));\n } else {\n throw new Error(\"We don't work in February!\")\n // or process.exit(1);\n }\n } else {\n if (appc.version.gte(appc.version.format(cli.version, 0, 3, true), '3.2.1')) {\n next(null, data);\n } else {\n next(data);\n }\n }\n },\n post: function (data, next) {\n logger.log('[FUNCTION-POST-HOOK] build.android.copyResource'.magenta);\n next(null, data);\n }\n });\n};\n{code}", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2014-02-04T22:51:41.000+0000", "updated": "2014-02-04T22:51:41.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }