Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1104] Fail build with clear message if controllers/index.js is missing

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2014-10-24T15:37:39.000+0000
Affected Version/sAlloy 1.4.0, Alloy 1.3.1, Alloy 1.4.1
Fix Version/sAlloy 1.6.0
ComponentsTooling
Labelsusability
ReporterFederico Casali
AssigneeFeon Sua Xin Miao
Created2014-08-01T00:18:55.000+0000
Updated2015-03-26T23:01:11.000+0000

Description

Problem description

Build fails on Android if the 'asset' folder is being deleted from the app project and is also not present in the Resources files folder.

Steps to reproduce

1. Create a new Alloy project 2. Delete everything in app folder except "views/index.xml" and "controllers/index.tss". Also delete config.json and alloy.js files. 3. Run on Android Result: app build and does not properly start with error:
[ERROR] TiExceptionHandler: (main) [438,438] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [1,439] - In ti:/module.js:280,9
[ERROR] TiExceptionHandler: (main) [0,439] - Message: Uncaught Error: Requested module not found: alloy/CFG
[ERROR] TiExceptionHandler: (main) [1,440] - Source: 		throw new Error("Requested module not found: " + request);
[ERROR] V8Exception: Exception occurred at ti:/module.js:280: Uncaught Error: Requested module not found: alloy/CFG

Comments

  1. Tim Poulsen 2014-08-20

    I posed the question to the Titans: {quote} There’s a minimal set of files/folders required for a valid project (controllers/index.js & views/index.xml for sure, but perhaps config.json, alloy.js, an assets folder, etc.). What should happen if you attempt to build a project that is missing something from that minimal set? A) The compile fails with a helpful message B) The build proceeds anyway, with the tooling creating temp versions of the missing files C) The tooling creates the missing files for you in your project’s directory {quote} Their vote was C, plus output a red error message that described which files were created and why. Something like: "These missing, required files were created for you: \[list\]" We need to determine what that minimal set of files & folders is, check for those as part of compiling, create missing files/folders in the project directory, and output the message at the [ERROR] level.
  2. Tim Poulsen 2014-08-20

    Upon further discussion with the Titans, their opinion was refined to: There should be just one required file for an Alloy project, which is app/controllers/index.js. If it's missing, fail the alloy compile process with a suitable error message. If any other file or folder is missing, build anyway without an error message and without creating that file. This is specifically true for files that would be normally empty, such as config.json and alloy.js. But also for any of the other folders (views, assets, etc.) typically found in an Alloy project.
  3. Feon Sua Xin Miao 2014-08-21

    PR: https://github.com/appcelerator/alloy/pull/515 Functional review: 1. Create a new Alloy project 2. Remove all files and folders in app dir, only keep the app/controllers folder 3. Remove the content of app/controllers/index.js 4. Compile and run the app on Android, there should be no exception 5. Now remove the app/controllers folder 6. Compile the app on Android again, there should be an error message like the the following:
       [ERROR] :  Alloy "app" directory has no "controllers/index.js" file at "/Users/fmiao/Titanium_Studio_Workspace/ALOY-1104/app/controllers/index.js".
       [ERROR] :  Alloy compiler failed
        
  4. Feon Sua Xin Miao 2014-08-21

    [~skypanther] Could you please review this. Thank you! :)
  5. Tim Poulsen 2014-08-21

    PR merged. Please note that this change affects all platforms, not just Android as originally noted. Testing should be done for each platform, though make sure to clean the project (ti clean from the CLI) between each build attempt.
  6. Tim Poulsen 2014-10-23

    Reopen to backport to 1_6_X branch
  7. Feon Sua Xin Miao 2014-10-24

    1_6_X: https://github.com/appcelerator/alloy/pull/599
  8. Tim Poulsen 2014-10-24

    PR merged
  9. Eric Wieber 2015-03-26

    Verified fixed using: Titanium SDK 4.0.0.v20150325201813 Studio 4.0.0.201503232213 Appc NPM: 0.3.35 Appc CLI 0.2.192 Alloy 1.6.0-alpha Not having an index.js file in the controllers folder will result in an error indicating such. Projects with only an index.js file and no other files in the app folder will build and run.

JSON Source