Closed no-stack-dub-sack closed 7 years ago
Prerequisite | Version |
---|---|
MongoDB | ~ ^3 |
Redis | ~ ^3.2 |
Node.js | ~ ^6 |
npm (comes with Node) | ~ ^3 |
Updating to the latest releases is recommended.
If Node, MongoDB, or Redis are already installed on your machine, run the following commands to validate the versions:
$ node -v
$ mongo --version
$ redis-server --version
If your versions are lower than the prerequisite versions, you should update.
IMPORTANT: If you have never contributed to an open source project before, are unfamiliar with the git workflow, or need assistance with creating a local copy of the freeCodeCamp Alumni Network (FCCAN) repo, branching, branch naming conventions, etc., please see the Getting Started guide here.
Once you've established a local copy of FCCAN, you will need to do a few things before launching the application for the first time:
Install all of the project's dependencies:
create-react-app
and is configured to run a proxied server. This means npm install
needs to be run twice.$ npm run setup
alumni-network/client
.npm install
can also be run in each independently in each directory should you ever need to clear either node_modules
folder.Secrets and API keys:
PassportJS
GitHub strategy, you must have a GitHub ID and a GitHub secret for the app to run, otherwise you will be unable to login.Settings
> OAuth Apps
> Register a new application
.local-fccan
, give it a homepage of https://localhost:8080
(this doesn't really matter for now), and most importantly, give it an "Authorization callback URL" of https://localhost:8080/auth/github/callback
(8080 is the port the proxied express server will be running on).
IMPORTANT: Make sure there is no trailing slash at the end of your authorization url - you should enter it exactly as it is above.
.env
file into your root directory and name it .env
:
$ cp sample.env .env
.env
file for you to populate with the necessary API keys and secrets and will contain the MONGO_URL
environment variable for you to connect to your locally run database. .env
file. PassportJS
authentication to work. Your session secret can be anything you want, but for best practices, try to make it at least somewhat complex and only something you will remember. =
sign. The first few lines of your file should look something like this:
MONGO_URL=mongodb://127.0.0.1:27017/alumninetwork
SESSION_SECRET=thisisasupercoolsessionsecretthatonlyIknow
GITHUB_CLIENT_ID=
- LinkedIn and Twitter API keys are optional and are only required if you will be developing against the features that utilize these APIs.
**Populating the Database and Running the App:**
- To run the app, you will need a minimum of 4 terminal/command prompt tabs for each of the following processes, which must be running for the app to work: `create-react-app` dev-server, NodeJS server, MongoDB, and Redis.
- First, launch MongoDB and Redis:
```bash
# in your first tab, in any directory, run:
$ mongod
# if you are a mac user and get an error, you may need to run:
$ sudo mongod
# and enter your password
#
# now, in your second tab, also in any directory, run:
$ redis-server
# in another tab, in the project's root directory, run:
$ npm run populate-db
# if this is successful, you should see a success message in the command prompt console
# if you get an error, please make sure mongo is running and try again
# in your third tab, in the project's root directory, run:
$ npm run dev
# this will start the NodeJS server
#
# in your fourth tab, from the project's root directory
# change directories to alumni-network/client
$ cd client
# and run
$ npm start
# this will start the CRA dev-server
BONUS: In addition to the 4 tabs required to run the app's various servers and databases, we recommend utilizing at least 2 other command prompt/terminal tabs. One for interacting with MongoDB (which you can do by running
$ mongo
from the command line), and another for general navigation, additional commands, and for managing the project's Git workflow.
SUMMARY: To summarize the previous section, and for running FCCAN each time after initial setup, the commands are:
# Tab 1: Run MongoDb $ mongod # Tab 2: Run Redis $ redis-server # Tab 3: Run NodeJS Server $ npm run dev # Tab 4: Run CRA dev-server $ cd client $ npm start
NOTE: Our registration process requires that users have a GitHub account, a freeCodeCamp account, and at least one FCC certification to join. However, we do not want this limitation to prevent potential contributors from gaining access to the application for development.
If you are not FCC certified, we have included a workaround setting that can be changed for development only:
server.js
, located in the project's root directory. ~15
, you should see the following export
statement:
export const isAllowed = false;
true
, save your changes and run the server (if it is not already running), and you will now be allowed in to the app.NOTE: We built this project using Chrome as our default browser, and for the best development experience and seamless dev-tools integration, we recommend you do the same.
- This project is configured to use both React and Redux dev tools. You can get them for Chrome here:
- React
- Redux
- Another useful utility that's value goes beyond the scope of this project is Mongo Hacker. This package is a series of Mongo Shell enhancements that makes interacting with MongoDB from the command line more seamless and less visually taxing.
- It can be installed by running the following commands: NOTE: Do not run these commands in the FCCAN project directory, you should run these in your project's parent directory, e.g.
/Users/your_name/myCodingProjects
, or in another preferred directory.$ git clone --depth=1 https://github.com/TylerBrock/mongo-hacker.git $ cd mongo-hacker $ make install
NOTE: For more complete documentation, please see the Mongo Shell documentation here.
- While working on this project, you may find it helpful to interact with MongoDB from Mongo's built in Mongo Shell. You can access this shell by using the following command from your command prompt/terminal:
$ mongo
- Here are some helpful commands and tips to get you started:
# before running any of the following commands # switch to the FCCAN database by using: $ use alumninetwork # # list all collections within alumninetwork db: $ show collections # # see all entries of a particular collection # ex: $ db.users.find({}) # or $ db.privateChat.find({}) # # these searches can be refined further: $ db.users.find({ username: "no-stack-dub-sack" }) # # you may occasionally want to reset your project's DB to test # certain features like registration (which you will only go through # the first time your user document is added to the database): $ db.dropDatabase() # WARNING: this cannot be undone and is tantamount to deleting # all of your project's stored data! If you need to preserve your # current settings, this is NOT recommended.
- Like in other shells, note that you can use the ↑ and ↓ keys to cycle through recent commands.
- There are other commands that you may find helpful, so don't forget to check out the documentation!
For responsive design, layout, theming, and general UI design, we have chosen to utilize Semantic-UI over some of the more common libraries like Bootstrap. We made this choice for 2 reasons: 1) We already knew Bootstrap and we wanted to learn something new, and 2) Semantic-UI rocks! We think you'll like working with it too.
Some notes on Semantic-UI:
On Theming:
Color | Class Name |
---|---|
Green | green |
Dark Green | teal |
Red | red |
Grey | grey |
Dark Grey | black |
Light Red | pink |
green
, except in special cases. For a full list of colors and their class name mappings, see this file. Consistency is fantastic! However, this project isn't. At least from a CSS standpoint 😄 . While we relied heavily on Semantic-UI for our general UI design and styles, more granular styles are always necessary to achieve the right level of control. For this, we used 3 different approaches to styling the UI:
Why Styled-Components?
When to use Styled-Component and When to Not:
Some Tips:
style-utils
file).${}
template literal syntax, e.g.:
import styled from 'styled-components';
import { thisFunctionReturnsCSS } from './style-utils';
const Text = styled.span border: 1px solid red; ${ thisFucntionReturnsCss() }
;
- Our [`hoverTransition`](https://github.com/FCC-Alumni/alumni-network/blob/master/client/src/styles/style-utils.js#L39) function is a great example of a reusable, global style that can be invoked in any styled-component (since all styled-components rely on template literals).
- This code might not make sense out of context, however, this is a very powerful concept that's worth pointing out. And after checking out our codebase and the Styled-Components docs, this will all make much more sense!
### This file is a WIP!
yourUsername/alumni-network
/yourprojectdirectory/
)$ git clone https://github.com/<yourUsername>/alumni-network.git
<yourUsername>
with your GitHub Username)This will download the entire FCCAN repo to your project's directory.
cd alumni-network
)$ git remote add upstream https://github.com/FCC-Alumni/alumni-network.git
Congratulations, you now have a local copy of the FCCAN repo!
Now that you have a copy of your fork, there is work you will need to do to keep it current.
Do this prior to every time you create a branch for a PR:
master
branch$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
If your aren't on
master
, resolve outstanding files / commits and checkout themaster
branch
$ git checkout master
upstream
$ git pull --rebase upstream master
This will pull down all of the changes to the official master branch, without making an additional commit in your local repo.
$ git push origin master --force
This will overwrite the master branch of your fork.
Before you start working, you will need to create a separate branch specific to the issue / feature you're working on. You will push your work to this branch.
Name the branch something like fix/xxx
or feature/xxx
where xxx
is a short description of the changes or feature you are attempting to add. For example fix/email-login
would be a branch where you fix something specific to email login.
To create a branch on your local machine (and switch to this branch):
$ git checkout -b [name_of_your_new_branch]
For example:
$ git checkout -b fix/minor-typo
and to push to GitHub:
$ git push origin fix/minor-type
@no-stack-dub-sack overall this looks great! Some notes:
"setup": "npm install && cd client/ && npm install
, similiarly to how we configure the deployment command to manually install the dependencies in the client folder before running the server.env
variables we could have some instructions like FCC has with a sample-env.env
file which we have the users cp sample-env.env .env
or whatever the command is. Lolz I just saw you created this already.--rebase
flag is only necessary in a git pull
if you have local commits you are trying to rebase on top of remote changes, I believe. So if someone just wants to update their local repository they could just run git pull upstream master
but the rebase doesn't hurt and I know the FCC writes the instruction like that too I think. The rebase however might be more necessary for them to rebase before actually submitting a pull request if changes have been introduced in the original code and there could be conflicts and if you want to enforce that it's up to the user to resolve conflicts by rebasing for instance (however, I think it's OK in an event like that to just resolve the conflicts yourself and merge it as long as the PR is good).master
back to their remote fork.And the last thing is that hopefully we'll consolidate the current beta issues and the other ideas we collected in a nice organized way (I guess just as issues) and then present those within the Contributing guide (as in just be like hey there are a lot of issues ready) as known challenges that would be good targets for someone looking to make a contribution — with the idea being that we're trying to facilitate a learning environment for someone to make open-source contributions.
@bonham000
And, we'll need something somewhere that explains how to actually run the app which I assume you were going to add.
☝️ for sure, not quite done yet, just haven't gotten there yet
Then I assume we'll have to suggest the user configures their on GitHub authentication credentials and adds those on their own.
☝️ Actually, I had already written this part, and is one of the main things I wanted you to look over to make sure it all looks right. See the 3rd bullet of the "Secrets and API Keys" section
We may not need the line about forcing pushing their local copy back to GitHub, it's not really necessary for them to push master back to their remote fork.
:point_up: agreed, but also can't hurt. I'm indifferent on whether its kept or not.
As far as rebasing goes, it can't hurt - for more experienced contributors, they will know the difference, for newer ones, rebasing is a safer bet I think
The script for setup is a good idea, I left a comment above about that!
resolved :-)
Starting a draft of the file here...