This is the home of the front-end code for the CIVIC Platform. It's organized in a monorepo using Yarn Workspaces, but it's ok if you don't know what that means yet.
Civic magic happens when we work together. We welcome your collaborative contributions. We also have a more technical contribution guide.
π§ I see something that could be better: The first step is open an issue, and tell us what you see that could be better. Tell us about your vision so that we can see what you see and help to improve it.
π¦ I want to work on making something specific better: If there's already a documented issue about what you want to work on, assign yourself to let others what you're working on. If there's not an issue, open one and assign yourself.
π€ I want to work on making something better, but I'm not sure where to start: Check out our open issues with the good-first-issue label for things to work on and open pull requests with the good-first-review label to review and collaborate with others on existing efforts.
π¦ I've done something towards making this better: Fantastic! Share it with us by opening a pull request with what you've done so far, and let's work together to make it even better and incorporate it into the CIVIC Platform!
π¦ I want to explore more things:
CIVIC Platform π Components and Style Guide (Storybook) π Platform Architecture Guide π Redux Guide π Contributing Guide
Before you install and build, you'll need the following.
-
bash
You will need a Unix shell (bash). For Mac, this can be Terminal.app. For Windows, you'll need to use Windows Subsystem for Linux (see issue #53).
-
nvm and yarn
You will need the following tools installed in your Unix shell:
These tools make sure every contributor has identical dependency versions, include node and node packages.
-
git
You will need to have Git installed in your bash environment.
πΈGENTLE WARNINGπΈ: Make sure you have met the prerequisites βοΈ
# Clone the repository using either https or ssh
# https
$ git clone https://github.com/hackoregon/civic.git
# OR ssh
$ git clone [email protected]:hackoregon/civic.git
$ cd civic
# Sets your Node.js version to match what the project uses.
$ nvm use
# Note for next two steps, if you get an error, keep trying the same command again.
# Installs all package dependencies and links cross-dependencies.
$ yarn install
# This will build all packages. Since some packages are used internally, they need to be built before the dependent packages are worked on.
$ yarn build
# Take a pizza break! π! This takes a while, but only needs to run at the project root once.
In order to be the most productive, youβll want to install some extensions or plug-ins for your text editor. These tools are already installed and configured project wide, so the only installation youβll need is inside your text editor (donβt npm install
or yarn add
them). There are plug-ins or extensions available for the most commonly used editors (VS Code, Sublime Text, Vim, WebStorm, Atom, etcβ¦)
πΈGENTLE WARNINGπΈ: Configuration still in progress. You may encounter linting errors. You may want to turn off Prettier and ESLint in your editor for the time being
- EditorConfig β for consistency in settings like indentation line-endings
- ESLint β to show linting in your editor as youβre coding
- Prettier β for code formatting in your editor as youβre coding
At this point, Yarn has prepared all packages in the monorepo.
Most developers working in this project will be contributing to one package at a time.
This is the command sequence that will allow you to build/run an individual package every time (for example, the housing
package)
and work on it as if it was a standalone project:
$ cd packages/{package-name} # e.g. cd package/2018-disaster-resilience
# run local project
$ yarn start
# test local project
$ yarn test
# watch tests while working on them
$ yarn test --watch
We are committed to a shared component library. This is achieved using the component-library
package and React Storybook.
Run Storybook with the following command or view it here:
# run this command from project root (civic)
$ yarn storybook
In separate terminals, run the commands in the Working on a single package other than the component library and Working on the component library using Storybook sections above. Project packages rely on the built version of the component library, so if you have updated the component library, and want to see your changes in the project package you are working on, you'll need to rebuild the component library. Once the component library build has finished, your project package will reload with the update components.
$ cd packages/component-library
# rebuild the component library
$ yarn build
There are three types of packages right now:
- Project packages: A React/Redux codebase that holds a collection of stories and API interactions for a single project in a Hack Oregon project cycle.
- Year package bundles: A React/Redux codebase that bundles together all project packages for a given year. This is a unit that gets deployed to production.
- Utilities: Common code that other projects depend on.
Every package has its own README with further details on what the package is for and how it works. We'll be adding some new packages for the 2019 project season.
-
Year Packages
-
Project Packages
-
Utilities
To run all tests for all packages, use the following command:
yarn test
Tests for individual packages can be run from within the individual package's directory. Running all tests is useful for continuous integration environments as well as verifying changes to common dependencies does not break packages.
For example, run the above command at the root of the project after making changes to a component in the component library to ensure that others packages are compatible with the changes made.
Travis CI is configured to have a build pipeline for the component library and one for each project year. Although most
commands are run using yarn scripts attached to a package.json
file, due to the many steps required to run tests for
a specific set of packages, a Makefile is used instead.
Travis CI will deploy docker containers to ECS for each project year whenever the master
branch builds successfully.