elasticio / elasticio-cli

Command-line interface for elastic.io components
2 stars 1 forks source link

Problems with the current code #19

Closed hannah-bulmer closed 4 years ago

hannah-bulmer commented 4 years ago

Some problems that either need to be addressed in the README or fixed somehow to be less error prone in codebase:

  1. Code always tries to read .env variables with handlebars, even when there are none, resulting in error messages being displayed each time that state Like this

    About to read file: C:\Users\Hannah Bulmer\elastic.json
    File does not exist: C:\Users\Hannah Bulmer\elastic.json
    File C:\Users\Hannah Bulmer\.env does not exist
  2. FIXED - Fixtures quit immediate after mistying When given the option to select your fixture, if you type one that is wrong the program immediately quites.

    A neat solution to fix this would be to use inquirer.js or a similar prompting library to provide the fixture options as a selectable list, rather than being given the options and having to type it yourself Furthermore, if there are no fixtures within the fixture object, you should not have the option to select '' as a fixture and have the program immdiately error out, like it currently does.

  3. FIXED - if process doesn't end with an emit.end() statement, the code never ends

  4. Add the rest of the this.emit() options to the event emitter These are

    scope
        .on('data', onData)
        .on('error', onError)
        .on('rebound', onRebound)
        .on('snapshot', onSnapshot)
        .on('updateSnapshot', onUpdateSnapshot)
        .on('updateKeys', onUpdateKeys)
        .on('httpReply', onHttpReply)
        .on('end', onEnd);
  5. FIXED If data is returned from process and not emitted, it should still be printed to the console somewhere at some point

  6. Improve error messages Things like missing msg in the fixtures file and such are easy to throw human-readable errors for, rather than printing the stack to screen for every error as it does now. We should improve this error handling to make building new portions of the program easier as well.

    Sometimes messages have colours for error messages and stuff, and sometimes they don't. This should probably be more consistent

  7. FIXED - Provide somewhere a blank fixtures template, maybe in the README?

  8. FIXED Improve the search for the test/fixtures.json file. Currently, this code is very messy and error-prone. One solution is to have user provide a path to the component as a flag and then the action/trigger name as a separate flag, but keeping the current mechanism we need to devise a smarter way to determine the location of test/fixtures.json that doesn't rely on a line like while (curDirectory !== '/'), which isn't compatible on non Macs.

TODO: