freeCodeCampLondon / FCCLND

Portal for FCC London Campers
https://FreeCodeCampLondon.github.io/FCCLND/
MIT License
32 stars 16 forks source link

JS: Simplify Switching Main Datasource #13

Closed chris-alexander closed 8 years ago

chris-alexander commented 8 years ago

Rewrite the angular files so that switching between running the app from Firebase and running the App from Local JSON is easier.

chris-alexander commented 8 years ago

I've managed to refactor the code to use a variable for switching the datasource. I am looking at the options for using an environment variable instead or even the use of flags when we run gulp: e.g.

gulp --env=production

hopefully this won't take long to figure out. I will submit a PR when it is ready.

artitudinale1 commented 8 years ago

ok no probs. I'm writing gulp for dist now. My idea is trying to have the dev environment run on a port let s say 3000 and dist env running on other so with just

gulp

they run everything but in different location. I ll try to submit EOP today so you can refactor and improve with switcher local/firebase. Is that ok?

chris-alexander commented 8 years ago

The /dist folder needs to be a compiled version of the app that can be deployed as static assets to gh-pages. So it needs:

So it wouldn't run on a port. When we implement it as a full-stack app then we will need a port and to run it on a server like express, but for now all we need is the static compiled assets.

artitudinale1 commented 8 years ago

I'm not talking about a port for serving outside, but for testing. I have created two instances of browserify one serving /dist/app and other /dev/app So you can check both are fine . It' s just for testing not deploying.

chris-alexander commented 8 years ago

Oh ok fair enough. :+1:

chris-alexander commented 8 years ago

So I want to do this in 2 stages:

  1. Refactor the Angular code to change the data source based on a variable (ready to merge now)
  2. Wait for the gulp build task to be finished and some tasks which replaces the text where the variable is defined (using gulp-replace) for the following scenarios:
    • by default when you run gulp = Local JSON
    • a flag to run with Firebase in dev: gulp --prod = Firebase
    • when the build task is run (gulp build) it will change the variable to run from Firebase

One downside to this setup is that if you change the variable manually it will ignore what you have put and replace it based on the scenarios above.

artitudinale1 commented 8 years ago

"One downside to this setup is that if you change the variable manually it will ignore what you have put and replace it based on the scenarios above." That s why I'm not too keen to use gulp for it and I d try to go with a external config file or something like this. I will look into it asap and let you know.

chris-alexander commented 8 years ago

ok cool let me know what you come up with 👍

chris-alexander commented 8 years ago

I think I should still do it for the deploy task to ensure that we are always working from Firebase before deploying. What do you think?

artitudinale1 commented 8 years ago

Absolutely go for it :+1: