|
7 | 7 |
|
8 | 8 | echo "Initializing Storybook for Varbase..."
|
9 | 9 |
|
| 10 | +# Install necessary dependencies for Storybook. |
10 | 11 | yarn install
|
11 | 12 |
|
| 13 | +# Store the current working directory path for later use. |
12 | 14 | current_path=$(pwd);
|
13 | 15 |
|
| 16 | +# Enable the Storybook module in Drupal. |
14 | 17 | drush pm:enable storybook
|
| 18 | + |
| 19 | +# Grant "render storybook stories" permission to both anonymous and authenticated users. |
15 | 20 | drush role:perm:add anonymous 'render storybook stories'
|
16 | 21 | drush role:perm:add authenticated 'render storybook stories'
|
17 | 22 |
|
| 23 | +# Copy the `development.local.services.yml` file to "docroot/sites/default/" directory. |
18 | 24 | cp ${current_path}/.ddev/commands/web/assets/development.local.services.yml ${current_path}/docroot/sites/default/
|
19 | 25 | echo "Copied the development.local.services.yml asset file to the ${current_path}/docroot/sites/default/ directory."
|
20 | 26 |
|
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