Cambridge Initial Setup
This repo contains the initial composer.json
file and local DDEV setup to create a local development environment.
Install DDEV
Install instructions: https://ddev.readthedocs.io/en/stable/
Drupal local site setup and management
Initial setup
Start DDEV:
ddev start
Install new Drupal site:
ddev init
Refresh and rebuild
To update Drupal profile, modules and theme and KEEP you current installation and Drupal content:
ddev refresh-drupal
To update Drupal profile, modules and theme and REINSTALL Drupal from scratch (will delete existing Drupal content):
ddev rebuild-drupal
Working with Composer dependencies
This project uses a custom upstream: https://docs.pantheon.io/guides/custom-upstream/manage-dependencies-custom-upstream
As such, the composer depdendencies are managed within upstream-configuration/composer.json
and upstream-configuration/composer.lock
Add new dependency
ddev composer --working-dir=upstream-configuration require drupal/xxxx
Remove existing dependency
ddev composer --working-dir=upstream-configuration remove drupal/xxx
IMPORTANT: composer.lock should not be added to git
The .gitignore
directory is shared between this local development environment and Pantheon upstream sites. Because of this, the root composer.lock
file should not committed to git, it also cannot be added to .gitignore
You should avoud committing this root composer.lock file.
You should commit upstream-configuration/composer.lock
Patches are managed in the root composer.json
file as normal.
Working with git
Local development of this repository uses gitflow.
Setup and usage can be found here: https://danielkummer.github.io/git-flow-cheatsheet/
Note that all defaults should be used during setup, so that (for example), git flow feature start AM-123
results in a local branch named git flow feature start feature/AM-123
Pre-commit hooks
Pre-commit hooks are set up to run checks against the theme in web/themes/custom/cambridge_tailwind
You must have the following installed to run the pre-commit hooks:
-
node
globally -
npm
globally -
pre-commit
globally
Setup
To install all local theme dependencies, run this from the theme directory web/themes/custom_cambridge_tailwind/
:
ddev npm install
To install all pre-commit hooks, run this from this root directory /
:
pre-commit install
This will perform checks defined in .pre-commit-config.yaml
before committing, including:
- Running prettier & eslint for code formatting and linting
- Consistent file endings / no trailing whitespace
- Consistent formatting of yaml and json files
- etc.
To run these checks manually, run pre-commit run -a
from this root directory.
Storybook development
To start a watcher for Storybook Twig components and twig files:
cd web/themes/custom/cambridge_tailwind
ddev npm run watch
Then open https://cam.ddev.site:6006/ to see Storybook.
Note that the above command runs inside the ddev docker container. All additional npm commands should also be run inside the container with
ddev npm [your command]