NOTE: Documentation assumes you are using MacOS with at least 8GB of memory on an Intel, M1, or M2 processor
👏 Thank you for considering to contribute to the YaleSites Platform!
- Contact YaleSites for access to resources such as Pantheon, Figma designs, etc.
- GitHub
- SSH authorization key
- Github Package Personal Access Token in environment variable
YALESITES_BUILD_TOKEN
- NVM
- Node.js (>= 8.0, < 11.0)
- Composer: Version 2.x.
- Terminus: Machine auth token
- Lando
- Docker: Use the version Lando wants to install and increase memory resources to at least 3GB memory and 3 CPUs if possible
- Project Setup
# Set up local development version of repo git clone [email protected]:yalesites-org/yalesites-project cd yalesites-project npm run setup
- Project Commands
Repositories used to make the platform:
- Yalesites Project: Drupal Platform Site (This repo)
- Yalsites Project Profile modules: Each subdirectory should have a README describing the function
- Atomic Theme: Atomic Drupal Theme bridging the Drupal site and the component library
- Component Library Twig: Component Library
- Tokens: Style tokens from Figma used to drive design of the platform and components
- ESLint Config and Other Formatting: Reusable Linting/Formatting included in the project
While the project can be cloned and run locally without it, one must setup an SSH key on their development machine if they wish to push code on any of the yalesites repositories. Luckily, GitHub has an intuitive guide on how to setup an SSH key on your machine and register it with your GitHub Account
Each environment that needs to pull @yalesites-org packages from GitHub needs to be authenticated using a "Personal Access Token". This only needs to be done once per-environment.
-
Go to
https://github.com/settings/tokens/new
- In the "Note" field add something like "YaleSites GitHub Packages"
- Choose an expiration value
- Check the box for "write:packages" (this will automatically check all of the "repo" boxes as well)
- Click "Generate token"
-
On your local machine, create an environment variable. This process varies depending on the shell and operating system you use. It will be something similar to this though:
export KEY=value
.- The
key
for YaleSites projects needs to beYALESITES_BUILD_TOKEN
- The
value
is the token you created above
- The
-
Done!
-
Here's a stack overflow post showing how to set persistent environment variables for various shells
Pantheon's Terminus is a command-line tool for managing sites. The CLI is required to run many of the scripts for building, updating, and deploying changes between the local development environment and the Pantheon platform.
- Install Terminus
- Setup a valid machine token
- Log in to terminus using the machine token
terminus auth:login --email=<[email protected]> --machine-token=<machine_token>
- Review documentation to get started with the CLI
This project supports development with Lando using the Pantheon recipe. This produces a local development environment that matches the hardware and configuration of the Pantheon platform. Most local tooling, including Composer, Drush, Drupal Console, and node applications are available through this recipe.
- Review the preflight checks
- Download and install the latest release
- Setup local certificate authority
- Increase Docker resources: Locate the 'Resources' section in your Docker preferences. For most architectures, this project requires at least 3GB of memory and 3 CPUs. Additional CPUs and memory may be helpful but should stay under the halfway mark of your total available resources. Also disable the 'Start Docker when you log in' setting under the 'General' tab.
- Composer: PHP package manager. Version 2.x. (Can use lando instead if you prefer)
- NVM: Node Version Manager
- Node.js (>=8.0,<11.0). Via NVM.
To clone the project, the above requirements must be met first. If you have not already cloned the repository:
git clone [email protected]:yaleitsites-org/yalesites-project.git
This repository is a Pantheon Custom Upstream used to create and manage every site on the YaleSites platform. Out of the box this project is not connected to an individual Drupal site. To contribute to this project, we need to connect the local development environment to a Drupal site to leverage the site's files and database.
# Executing the setup script will prepare the local development environment.
npm run setup
Visit the local dev site https://yalesites-project.lndo.site/ or run lando drush uli
to obtain a login link.
The steps in this section are completed in the aforementioned setup script.
The YaleSites platform organizes work across a series of custom modules, themes, and an installation profile. To avoid an unnecessarily monolithic architecture, each of these dependencies exist in unique repositories that are included via composer. The previously created local development environment is an ideal place for working on these projects within the context of a YaleSite.
By default, composer dependencies are downloaded in a dist packaged version of the project with git metadata removed. When working on a Yale-managed package such as Atomic or the Component Library, the originally downloaded composer dependency must be replaced with the source packaged version. This allows any changes to be tracked in version control.
The YaleSites Atomic theme is a flexible Drupal theme based on the YaleSites design system. The theme is included in the YaleSite installation profile and is the default theme for all new web properties.
# Step 1: Configure Composer to use source packaged versions.
lando composer config --global 'preferred-install.yalesites-org/*' source
# Step 2: Manually remove the originally downloaded dist packaged version.
rm -rf web/themes/contrib/atomic
# Step 3: Use Composer to download the new version of the thme.
lando composer update atomic
# Step 4: Verify that the theme is tracking a remote repository.
git -C web/themes/contrib/atomic ls-remote --get-url
# Returns: https://github.com/yalesites-org/atomic.git
# Step 5: Setup npm linked packages for theme dependencies
npm run local:theme-link
NOTE: There are more commands, but these are those that current developers feel are most used.
npm run setup # Setup whole environment
npm run build-with-assets # Build/Rebuild with replaced assets
npm run build-with-install # Rebuild with fresh imports
npm run local:git-checkout # Sync:
# yalesites-project: develop branch
# atomic: main branch
# component-library: main branch
# tokens: main branch
npm run local:git-checkout -- -h # More command help
npm run confex # Export drupal configuration
npm run confim # Import drupal configuration
npm run db:get # Download a dev database locally from a pantheon site
npm run files:get # Download dev files locally from a pantheon site
npm run lint # Lints js, php, and styles
npm run fix:js # Fixes js linting errors if possible
npm run test # Runs prettier and linting
lando composer code-sniff # Test for PHP linting issues that CI tests against