Drupal site for Princeton Research Data Service
Note: depends on Lando 3.0.7 or higher https://github.com/lando/lando/releases
git clone git@github.com:pulibrary/researchdata.git
cp sites/default/default.settings.php sites/default/settings.php
- Add the following to the end of
sites/defaults/settings.php
. You will get the values forhash_salt
later, after thelando drush rsync
step.if (file_exists($app_root . '/sites/settings.local.php')) { include $app_root . '/sites/settings.local.php'; } $databases['default']['default'] = array ( 'database' => 'drupal10', 'username' => 'postgres', 'password' => '', 'prefix' => '', 'host' => 'database', 'port' => '5432', 'namespace' => 'Drupal\\Core\\Database\\Driver\\pgsql', 'driver' => 'pgsql', ); $settings['hash_salt'] = '<Hash Salt>'; $settings['config_sync_directory'] = 'sites/default/config';
mkdir .ssh
# excluded from version controlcp $HOME/.ssh/id_ed25519 .ssh/.
cp $HOME/.ssh/id_ed25519.pub .ssh/.
// key should be registered in princeton_ansible deploy rolecp drush/sites/example.site.yml drush/sites/researchdata.site.yml
- Uncomment the alias blocks in the
drush/sites/researchdata.site.yml
. lando start
lando drush @researchdata.prod sql-dump --structure-tables-list='watchdog,sessions,cas_data_login,history,captcha_sessions,cache,cache_*' --result-file=/tmp/dump.sql; scp pulsys@prds-prod2:/tmp/dump.sql .
lando db-import dump.sql
lando drush rsync @researchdata.prod:%files @researchdata.local:%files
- In order to get the value for
$settings['hash_salt']
, runls sites/default/files | grep "config" | sed "s/config_\(\S*\)/\1/"
on the command line, and put the result in yoursites/defaults/settings.php
- Create a
drush/drush.yml
file with the following:options: uri: http://researchdata.lndo.site
lando drush uli --name=your-netid
Each time you pull from main it is a good idea to check the status of your site. To check and see if you need to get changes run
lando drush config:status
If everything is up to date you will see
[notice] No differences between DB and sync directory.
If there are changes you need to import you will see something like (note: Only in sync dir in the State)
---------------------------------------------------- ------------------
Name State
---------------------------------------------------- ------------------
core.entity_form_display.node.a_z_resource.default Only in sync dir
If there are changes you need to export you will see something like (note: Only in DB in the State)
---------------------------------------------------- ------------
Name State
---------------------------------------------------- ------------
core.entity_form_display.node.a_z_resource.default Only in DB
Most of the time you will want to import the entire configuration. The only time this would not be the case is if you have some states that are Only in DB
and some the are Only in sync dir
(You made changes and another developer have made changes). To import the entire configuration run lando drush config:import
or lando drush config:import -y
. If you run without the -y you will see a list of the changes being made before they get applied like below:
+------------+----------------------------------------------------+-----------+
| Collection | Config | Operation |
+------------+----------------------------------------------------+-----------+
| | field.storage.node.field_resource_link | Create |
| | node.type.a_z_resource | Create |
| | field.field.node.a_z_resource.field_resource_link | Create |
If you have both exports and imports see the section below.
Most of the time you will want to export the entire configuration. The only time this would not be the case is if you have some states that are Only in DB
and some the are Only in sync dir
(You made changes and another developer have made changes). To export the entire configuration run lando drush config:export
or lando drush config:export -y
. If you run without the -y you will see a list of the changes being made before they get applied like below:
[notice] Differences of the active config to the export directory:
+------------+----------------------------------------------------+-----------+
| Collection | Config | Operation |
+------------+----------------------------------------------------+-----------+
| | field.storage.node.field_resource_link | Create |
| | node.type.a_z_resource | Create |
| | field.field.node.a_z_resource.
+------------+----------------------------------------------------+-----------+
The .yml files in your export directory (sites/default/config) will be deleted and replaced with the active config. (yes/no) [yes]:
> yes
[success] Configuration successfully exported to sites/default/config.
If you have both exports and imports see the section below.
You made changes and another developer have made changes, and now the configuration must be merged.
We will use git to combine the two configurations.
- Check to make sure everything is committed in git with
git status
. Commit any untracked changes. - Export you local changes on top of the existing git changes.
lando drush config:export
- Double check you do not want keep any of the changes
for any file you want to keep the changes in
git status git diff <modified file>
commit those changes so they do not get lost with either agit add <modified file>
git commit
orgit commit --amend
- restore the lost changes tracked by git
git reset HEAD . git checkout .
- Import the changes both tracked and untracked
lando drush config:import
- Check your config status
lando drush config:status
- Commit your changes to git with a branch and a PR.
If you are using Chrome, go into the Network tab in devtools and select "Disable cache"
cd themes/custom/prds
lando npm install
lando gulp compile
to generate css and js for the theme (orlando gulp task-name
for specific task defined inthemes/custom/prds/gulpfile.js
)
Refer to cweagans/composer-patches.
We utilize capistrano to deploy the code out to the server. To deploy code to an existing server run
cap <server set> deploy
(for example cap production deploy
).
To import a database run cap <server set> drupal:database:import_dump SQL_DIR=<path to dump> SQL_FILE=<dump file name>
To install code on a blank sever you must deploy and upload a database, so you need to pass the database bump variables to the deploy command cap <server set> deploy SQL_DIR=<path to dump> SQL_FILE=<dump file name>
To see a list of al available command run cap -T
Tests are located in themes/custom/prds/cypress
cd themes/custom/prds
npm install
- Add the token from Percy located in Project settings.
npx percy exec -- cypress open
- In the Cypress dashboard, click on the
drupal.js
test to run the tests.