Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1652] CLI: Improve handling of missing directories and files in alloy new

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-06-19T15:22:49.000+0000
Affected Version/sn/a
Fix Version/sCLI Release 7.1.0, Alloy 1.14.0
ComponentsTooling
Labelsn/a
ReporterEwan Harris
AssigneeSamuel Haig
Created2019-03-14T17:47:17.000+0000
Updated2019-06-19T15:22:50.000+0000

Description

Description

Currently if an expected directory or file doesn't exist the alloy new command doesn't handle this very well and will just throw an error directly from node. We should handle these errors properly and log errors informing a user what file is missing. For example (this is just one example, there are probably more) 1. Create a titanium project using ti create or appc new --classic 2. cd into that dir 3. Call alloy new . ~/Documents
fs.js:119
    throw err;
    ^

Error: ENOENT: no such file or directory, lstat '/Users/eharris/Documents/app'
    at Object.lstatSync (fs.js:861:3)
    at /Users/eharris/Documents/git/alloy/node_modules/graceful-fs/polyfills.js:297:22
    at getStats (/Users/eharris/Documents/git/alloy/node_modules/fs-extra/lib/copy-sync/copy-sync.js:46:14)
    at startCopy (/Users/eharris/Documents/git/alloy/node_modules/fs-extra/lib/copy-sync/copy-sync.js:41:10)
    at Object.copySync (/Users/eharris/Documents/git/alloy/node_modules/fs-extra/lib/copy-sync/copy-sync.js:36:10)
    at module.exports (/Users/eharris/Documents/git/alloy/Alloy/commands/new/index.js:113:5)
    at Object.<anonymous> (/Users/eharris/Documents/git/alloy/Alloy/alloy.js:112:46)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/Users/eharris/Documents/git/alloy/bin/alloy:3:1)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
    at internal/main/run_main_module.js:21:11
That error should be handled correctly and we should log an error informing the user what is missing. We might wish to have a canned message on all messages saying something to the effect of "your template must have x, y and x". It would also be good to clear up the app directory created so that a user doesn't have to do this manually

Comments

  1. Samir Mohammed 2019-06-19

    *Closing ticket*, Fix verified in CLI Version 7.1.0-master.21 Able to see better handling of missing directories and files in alloy new. Tested using the the test steps in the description and able to see the following error:
       [ERROR] Project creation failed. 
       [ERROR] Project template "/Users/Samir/Documents" not found at "/usr/local/lib/node_modules/alloy/templates/Users/Samir/Documents"
       
    *Test Environment*
       SDK: 8.0.2.GA
       Operating System
         Name                        = Mac OS X
         Version                     = 10.14.4
         Architecture                = 64bit
         CPUs                      = 8
         Memory                      = 16.0GB
       Node.js
         Node.js Version             = 10.13.0
         npm Version                 = 6.4.1
       Appcelerator CLI
         Installer                   = 4.2.14-3
         Core Package                = 7.1.0-master.21
       Titanium CLI
         CLI Version                 = 5.2.1
         node-appc Version           = 0.2.49
       

JSON Source