[ALOY-1115] CLI command to create a project from an Alloy test case
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2014-09-22T04:53:26.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.7.0 |
Components | Samples & Templates, Tooling |
Labels | n/a |
Reporter | Tim Statler |
Assignee | Tim Poulsen |
Created | 2014-08-19T21:18:58.000+0000 |
Updated | 2015-06-08T21:39:26.000+0000 |
Description
In a recent email thread, [~skypanther] had an idea to add analloy
CLI to create a new Alloy project from a given sample, e.g. alloy create_sample basics/simple
. Moar:
bq. ...The samples are actually installed to the developer’s computer...as is a shell/template app. Such a command could merge the two, putting the resulting files in the developer’s workspace directory.
There is also a [doc ticket|TIDOC-1849] to better expose the samples, but this type of tool enhancement would be nice, too.
Comments
- Tim Poulsen 2014-09-16
PR https://github.com/appcelerator/alloy/pull/565
Functional test:
1. Create a new Titanium Classic project
ti create --name foo
2. Change to the project's directorycd foo
3. "Alloy-ize" the project, specifying the test app to import by adding the--testapp
parameter followed by the directory and name of the test app to import. E.g.alloy new . --testapp ui/tableview
4. Build the project for fun & profitti build -p ios
When testing, be sure to test on OS X and Windows (should work on Linux too). Make sure to do test builds for iOS, Android, and MobileWeb. On Windows, you should use the \ slashalloy new . --testapp ui\tableview
though in theory the / should work too. Notes: * None of the samples that require files outside of the app folder will work without additional steps. For example, you would need to create an i18n folder for the advanced/localization app. Or, you would need to install the native modules used by the advanced/native_modules app. * The "testing" apps (those used internally by Alloy developers) are not installed with the rest of Alloy. So, you cannot create a test app based on any of them. - Tim Statler 2014-09-18
This is awesome, Tim. My comments:
* The workaround for this is [already documented](http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Samples-section-37535160_AlloySamples-TestCaseExamples), but if the test app contains a specs folder you usually get runtime errors. Maybe the tool could alert the user to this if the target sample has a specs folder...maybe mention the same workaround? Might be asking too much, I realize.
* This is purely a personal preference (so take with grain of salt) but I'd prefer a command line option to the
testapp:
prefix, e.g.alloy new --testapp ui/tableview
. But I'm fine with the current approach. - Tim Poulsen 2014-09-18
Thanks for the feedback. I should be able to filter out copying the specs folder so that it wouldn't be a problem for users. I initially tried with a
--testapp
arg but it wasn't working and the prefix was easier for a proof of concept. But I'll see about reworking it to use the argument. - Tim Poulsen 2014-09-19
PR updated to implement
--testapp
arg rather than prefix method originally used. Also copying excludes the specs folder. Added a test to thejake test:spec\[new.js\]
test script. Functional test -- see my comment above. - Tim Statler 2014-09-19
Perhaps this is expected, but filtering out the specs/ folder doesn't fix the runtime errors, since apps require in the specs/index.js file, e.g.
Again, we can/do document this issue for users, but I wasn't sure if the expectation was that the filtering would fix the runtime error, which it doesn't.if (!ENV_PROD) { require('specs/index')($); }
- Tim Poulsen 2014-09-19 Ah, good catch. It was not my expectation that this change would catch runtime errors. There are a couple of other ways to handle this besides documenting the issue: * I could add an output message after you create an app with --testapp that reminds developers to remove the require() statement * Or, I could modify the scripts to also copy the testrunner harness files so that the specs would actually run Thoughts?
- Tim Statler 2014-09-19 I vote for copying the harness files, so it works out of the box.
- Tim Poulsen 2014-09-19
I updated the PR to copy both the specs and the necessary testing framework files. This new PR also excludes the _generated folder from the set of files copied. Functional test is the same as above, though if you test with the advanced/form_factor you can test that the specs work -- after using
alloy new
build and run the app. It should run without errors and the app's unit tests should run. - Feon Sua Xin Miao 2014-09-22 PR merged.