Skip to content

Commit b9b1fde

Browse files
committed
Add custom DDEV commands: install-varbase, init-storybook, add-testing-users, delete-testing-users #277
1 parent 8c0a57b commit b9b1fde

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

.ddev/commands/web/init-storybook

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,31 @@
77

88
echo "Initializing Storybook for Varbase..."
99

10+
# Install necessary dependencies for Storybook.
1011
yarn install
1112

13+
# Store the current working directory path for later use.
1214
current_path=$(pwd);
1315

16+
# Enable the Storybook module in Drupal.
1417
drush pm:enable storybook
18+
19+
# Grant "render storybook stories" permission to both anonymous and authenticated users.
1520
drush role:perm:add anonymous 'render storybook stories'
1621
drush role:perm:add authenticated 'render storybook stories'
1722

23+
# Copy the `development.local.services.yml` file to "docroot/sites/default/" directory.
1824
cp ${current_path}/.ddev/commands/web/assets/development.local.services.yml ${current_path}/docroot/sites/default/
1925
echo "Copied the development.local.services.yml asset file to the ${current_path}/docroot/sites/default/ directory."
2026

21-
grep -qxF "\$settings['container_yamls'][] = \$app_root . '/' . \$site_path . '/development.local.services.yml';" ${current_path}/docroot/sites/default/settings.ddev.php || echo >> ${current_path}/docroot/sites/default/settings.ddev.php; echo "// Enable the development local services for Storybook." >> ${current_path}/docroot/sites/default/settings.ddev.php; echo >> ${current_path}/docroot/sites/default/settings.ddev.php; echo "\$settings['container_yamls'][] = \$app_root . '/' . \$site_path . '/development.local.services.yml';" >> ${current_path}/docroot/sites/default/settings.ddev.php
22-
echo "Enabled the development local services for Storybook in the \`settings.ddev.php\` file."
27+
# When settings.ddev.php exists and is not empty, ensure development.local.services.yml is included in container settings.
28+
if [[ -f "${current_path}/docroot/sites/default/settings.ddev.php" && -s "${current_path}/docroot/sites/default/settings.ddev.php" ]]; then
29+
grep -qxF "\$settings['container_yamls'][] = \$app_root . '/' . \$site_path . '/development.local.services.yml';" ${current_path}/docroot/sites/default/settings.ddev.php || echo >> ${current_path}/docroot/sites/default/settings.ddev.php; echo "// Enable the development local services for Storybook." >> ${current_path}/docroot/sites/default/settings.ddev.php; echo >> ${current_path}/docroot/sites/default/settings.ddev.php; echo "\$settings['container_yamls'][] = \$app_root . '/' . \$site_path . '/development.local.services.yml';" >> ${current_path}/docroot/sites/default/settings.ddev.php
30+
echo "Enabled the development local services for Storybook in the \`settings.ddev.php\` file."
31+
fi
32+
33+
# When settings.platformsh.php exists and is not empty, ensure development.local.services.yml is included in container settings.
34+
if [[ -f "${current_path}/docroot/sites/default/settings.platformsh.php" && -s "${current_path}/docroot/sites/default/settings.platformsh.php" ]]; then
35+
grep -qxF "\$settings['container_yamls'][] = \$app_root . '/' . \$site_path . '/development.local.services.yml';" ${current_path}/docroot/sites/default/settings.platformsh.php || echo >> ${current_path}/docroot/sites/default/settings.platformsh.php; echo "// Enable the development local services for Storybook." >> ${current_path}/docroot/sites/default/settings.platformsh.php; echo >> ${current_path}/docroot/sites/default/settings.platformsh.php; echo "\$settings['container_yamls'][] = \$app_root . '/' . \$site_path . '/development.local.services.yml';" >> ${current_path}/docroot/sites/default/settings.platformsh.php
36+
echo "Enabled the development local services for Storybook in the \`settings.platformsh.php\` file."
37+
fi

0 commit comments

Comments
 (0)