Raathigesh / atmo

:heavy_check_mark: Mock data for your prototypes and demos. Remote deployments to Zeit now.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

version control entrypoints JSON file

pantchox opened this issue · comments

when loading atmo frontend (via global command) it loads the file ../../cache.spec.json
whenever we add/delete entrypoint in the frontend the changes are being "globaly" saved to that file.

When working on a project i don't want my team to do import/export on every change in the version control (i.e using the export/import buttons in the atmo frontend)
I prefer to click the save button and continue as is.

There for the solution i offer is that when calling atmo in the command line add the parameter cacheFilePath to load the specific cache spec file.
example atmo --logs --cacheFilePath mockups/db.json

to do this inspecting the server.js code in atmo/src/server/server.js there is a variable called cacehFilePath which loads the global entrypoints file ../../cache.spec.json.

a quick dirty way to change that line to:
var cacheFilePath = ( argv.cacheFilePath ? argv.cacheFilePath : null ) || path.join(__dirname, '../../cache/spec.json');
will make that when running atmo the default loaded file will be then one i specified (which is good for version controlled file) also add/delete entrypoints currently saving it to that specific file just works as expacted.

I would have create a PR but i am behind a firewall and will able to do in only in few days( sorry!)
Also the change i offered is a very dirty solution, it should be placed and checked in a better place in the server.js code.

Thanks.

This is a very valid use case. Maybe we could call the CLI parameter as specFilePath instead of cacheFilePath or maybe even something better.

One more thing to consider is how Atmo is going to get the updates when the specified spec file is updated. Should there be a refresh button in the UI? But then this refresh button should be displayed only when an external spec file is used through the newly introduced CLI parameter.

Another thing is to check that the loaded cache file is NOT read only.
version control systems tends to make the file READ ONLY there for this make atmo to crash, so if the loaded file is READ ONLY exit atmo and mention that the permission should be changed.
Thanks.

We could go ahead and implement this. But since I have already started working on a different project, it would be hard to find time to implement this asap. If you could send a PR, that would be awesome!

I will start working on a PR, but we have to think about this:

One more thing to consider is how Atmo is going to get the updates when the specified spec file is updated. Should there be a refresh button in the UI? But then this refresh button should be displayed only when an external spec file is used through the newly introduced CLI parameter.

Usually if the file is updated outside of ATMO it updated when someone do a PULL from a repo of the specFile.json, there for it is something we can not control of.
problem is that if i work on ATMO and i have created changes and didn't click save YET and the file is being updated via version control, clicking the save will override the changes OR if i just reload the page i will LOSE all my changes (i think, if ATMO reload file by frontend request of rendering).

My thinking is that if the file is being updated outside of ATMO it means the user is responsible for his own actions, clicking SAVE should overwrite it.

Another issue i wanted your attention is that if the cacaFile.json we refer in the argument is READ ONLY it should exit ATMO because ATMO anyway will crash, so how would you like to handle that READ ONLY error? just exit? or throwing an error which is good if you use WEBPACK for example.

Thanks, and waiting for you input.

Atmo is certainly moving away from CLI. #34

Feedback is always welcome!