Closed rwx-yxu closed 1 year ago
The CSV file provided to us for hcm is left to the developers to decide on how we want to process the data.
I am thinking of potentially having node check for the presence of the file in the root directory. If there is a 'hcm.csv' file, then parse the data into firestore. Otherwise start up and check that the the application can ping the db.
Will work on the happy path first with the firestore configs before parsing or checking on start up.
TODO:
There are larger implications how that I think about the .env file because I think that for this assignment, we need to make that available on the repo but I do not feel comfortable with putting API keys on a public GitHub repo.
Need to think of a way to have something like a .env.local file for dev and allow for .env to be pushed to the repo once the project is done.
Instead of a test document, would it be more sensible to have a "Setup" document that has values that tracks if the app has been setup? I could still have the test key value but, I could also have a key value for "{hcm_data_uploaded:false}"? So, in the app, I check for that and if it is false, I find the csv and parse it to post onto the db. This would be better than a standalone script that is a throw away and it wouldn't be a throwaway end point that we would have open.
Need to think of a way to have something like a .env.local file for dev and allow for .env to be pushed to the repo once the project is done.
So the pushed .env file will just access variables from the .env.local file?
No. The .env file is one that is available publicly. .env.local file will just be for local development that is not pushed to GitHub. Reason for making the .env file public is because I think that Ismail wants the config files for firebase visible along with the account passwords ect for the adv-grp1 accounts so we need to make a .env file publicly visible.
We will use .env.local for now and make push .env file public at the end of the project.
.env to be pushed to the repo once the project is done.
Wouldn't want the firebase config settings to be pushed right now during development. Saves time with putting .env in .gitignore now and then taking it off at the end to push .env. Whereas I can put .env.local in .gitignore and not bother with messing with that file at all.
Noticed that there is already a branch for core/fire-base-setup. Need to check with @LiamSingh64 on if he wants to dev it since he already has two commits in there. Branch was created without telling me despite the issue assigned to myself because I have access to adv-grp1 firebase account for the config info.....
Taking back ownership of dev after clarifying Liams stance. Since he wanted to make a start and leave it at that without informing me.
Liam had already pushed the .env file to source control. I think I'll add in a IS_DEVELOPMENT=false variable in there as a toggle between this .env or the .env.local file.
Vite has a way to manage env files https://vitejs.dev/guide/env-and-mode.html
Wont even need the toggle. Vite will auto import a .env file along with .env.local files.
Going to use csv-parser to parse the csv and fs to find the csv in the current directory.
Trying to do the parsing right now and I am getting this error when trying to use fs to read the file Cannot access "fs.existsSync" in client code.
Starting to learn that there is a difference between vite and nodejs. vite is the frontend development server which runs in the browser means that it is separate from the server side nodejs. This means that vite cannot have direct access to server files and cannot exit using process.exit(1).
This means that I am gonna need to write uploadHcmData.js as a standalone script and put the script command in package,json as a node script so that node can have access to local files.
Not sure if it is worthwhile to upload the hcm csv file
verified that the data has been uploaded to firestore.
Get the initial config to make firestore accessible.
Main objectives are to make main compatible with .env files for the fire store config.
I need to make the documents and collections manually in the firebase console as well.