Home of the Civic Platform frontend code.
This is a lerna based monorepo. Check out lernajs.io for any in-depth docs if you need to debug. Otherwise follow along:
Prerequisites you'll need in your development environment to use and contribute to this project.
These tools make sure every contributor has identical dependency versions, include node and node packages.
# Sets your Node.js version to match what the project uses (should also happen on clone)
$ nvm use
# Installs all package dependencies and links cross-dependencies
$ yarn bootstrap
# 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
At this point, Lerna 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/test an individual package every time (for example, the housing
package)
and work on it as if it was a standalone project:
# you can open a separate shell &
$ yarn watch # this will watch all packages and update builds
# back in your original shell, switch to the package you want to work with
$ cd packages/{package-name} # e.g. cd package/housing
# run local project
$ yarn start
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:
$ yarn storybook
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.
- 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.