Skip to content

Commit

Permalink
Switch to recipe-installer-kit (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
balsama authored Feb 7, 2025
1 parent a5e12fa commit da3cacb
Show file tree
Hide file tree
Showing 37 changed files with 1,043 additions and 19 deletions.
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"drupal/drupal_cms_seo_tools": "*",
"drupal/drupal_cms_starter": "*",
"drupal/mysql57": "^1.0",
"drupal/recipe_installer_kit": "^1.0@alpha",
"drush/drush": "^13"
},
"require-dev": {
Expand All @@ -65,6 +66,7 @@
"optimize-autoloader": true
},
"extra": {
"composer-exit-on-patch-failure": true,
"drupal-scaffold": {
"locations": {
"web-root": "docroot/"
Expand Down Expand Up @@ -100,8 +102,5 @@
}
}
},
"scripts": {
"update-profile": "./scripts/update-profile.sh",
"post-update-cmd": "@update-profile"
}
"scripts": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Acquia Drupal CMS Installer
type: profile

# Change this to whatever your minimum required version of core is, depending on the
# needs of the recipes you want to apply.
core_version_requirement: '^11.1'

# Change this to whatever you like. It's only visible to users in the installer's profile
# selection step, which is skipped if you mark this profile as a distribution.
description: 'Provides a recipe-based installer UI. Auto-generated from drupal/recipe_installer_kit'

# Remove this entire `distribution` section if you'd like users to choose which profile
# to use at the start of the install.
distribution:
name: Acquia Drupal CMS Installer
install:
theme: acquia_drupal_cms_installer_theme
finish_url: '/admin/dashboard/welcome'

# A list of forms that should be presented to the user before choosing database
# settings and installing the system. Each of these forms must implement
# \Drupal\RecipeKit\Installer\FormInterface.
forms:
- '\Drupal\RecipeKit\Installer\Form\RecipesForm'
- '\Drupal\RecipeKit\Installer\Form\SiteNameForm'

recipes:
# This should be a list of recipes' Composer package names that should always be
# applied during the install process.
required:
- drupal/drupal_cms_starter

# This should be a set of recipe combinations to show to the user as choices at the
# start of the install process. The keys should be the user-facing names of the
# combinations, and the values should be lists of the Composer package names of the
# recipes that make up that combination.
optional:
'Blog':
- drupal/drupal_cms_blog
'Case Studies':
- drupal/drupal_cms_case_study
'Events':
- drupal/drupal_cms_events
'News':
- drupal/drupal_cms_news
'Person Profiles':
- drupal/drupal_cms_person
'Projects':
- drupal/drupal_cms_project
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

use Drupal\Core\Form\FormStateInterface;
use Drupal\RecipeKit\Installer\Hooks;

/**
* Implements hook_install_tasks().
*/
function acquia_drupal_cms_installer_install_tasks(): array {
return array_merge(
['acquia_drupal_cms_installer_tweak_config' => []],
Hooks::installTasks(),
);
}

/**
* Implements hook_install_tasks_alter().
*/
function acquia_drupal_cms_installer_install_tasks_alter(array &$tasks, array $install_state): void {
Hooks::installTasksAlter($tasks, $install_state);
}

/**
* Implements hook_form_alter().
*/
function acquia_drupal_cms_installer_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
Hooks::formAlter($form, $form_state, $form_id);
}

/**
* Tell Package Manager about acquia/drupal-recommended-settings.
*
* @return void
*/
function acquia_drupal_cms_installer_tweak_config(): void {
$config = \Drupal::configFactory()->getEditable('package_manager.settings');

$additional_trusted_composer_plugins = array_merge(
$config->get('additional_trusted_composer_plugins'),
['acquia/drupal-recommended-settings']
);

$config->set(
'additional_trusted_composer_plugins',
$additional_trusted_composer_plugins
);
$config->save();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
Drupal\RecipeKit\Installer\RecipeAppliedSubscriber:
autowire: true
tags:
- { name: event_subscriber }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "drupal/acquia_drupal_cms_installer",
"type": "drupal-profile",
"require": {
"drupal/recipe_installer_kit": "^1.0.0-alpha2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: administrator
label: Administrator
weight: 3
is_admin: true
permissions: { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Acquia Drupal CMS Installer Theme
type: theme
core_version_requirement: '^11.1'
description: 'Themes the Drupal CMS installer. Not to be used in production.'
base theme: claro
libraries-extend:
claro/maintenance-page:
- acquia_drupal_cms_installer_theme/maintenance-page
core/drupal.progress:
- acquia_drupal_cms_installer_theme/drupal.progress
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
maintenance-page:
css:
theme:
css/gin-variables.css: {}
css/fonts.css: {}
css/installer-styles.css: {}
css/add-ons.css: {}
dependencies:
- core/once

drupal.progress:
js:
js/progress.js: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

declare(strict_types=1);

use Drupal\Core\File\FileUrlGeneratorInterface;

/**
* Implements template_preprocess_install_page().
*/
function acquia_drupal_cms_installer_theme_preprocess_install_page(array &$variables): void {
$theme_path = \Drupal::theme()->getActiveTheme()->getPath();
$variables['theme_path'] = \Drupal::service(FileUrlGeneratorInterface::class)
->generateString($theme_path);
}

/**
* Implements hook_form_FORM_ID_alter() for installer_site_name_form.
*/
function acquia_drupal_cms_installer_theme_form_installer_site_name_form_alter(array &$form): void {
$form['#title'] = t('Give your site a name');

$form['help'] = [
'#prefix' => '<p class="cms-installer__subhead">',
'#markup' => t('You can change this later.'),
'#suffix' => '</p>',
'#weight' => -100,
];
$form['site_name'] += [
'#prefix' => '<div class="cms-installer__form-group">',
'#suffix' => '</div>',
];
$form['actions']['submit']['#attributes']['class'] = ['button--next'];
}

/**
* Implements hook_form_FORM_ID_alter() for installer_recipes_form.
*/
function acquia_drupal_cms_installer_theme_form_installer_recipes_form_alter(array &$form): void {
$form['#title'] = t('Get started');

$form['help'] = [
'#prefix' => '<p class="cms-installer__subhead">',
'#markup' => t('You can select pre-configured types of content now, or add them later.'),
'#suffix' => '</p>',
'#weight' => -100,
];
$form['add_ons'] += [
'#prefix' => '<div class="cms-installer__form-group">',
'#suffix' => '</div>',
];
$form['add_ons']['help'] = [
'#prefix' => '<p class="cms-installer__info">',
'#markup' => t('Don’t see what you’re looking for? You can set up customized content later.'),
'#suffix' => '</p>',
'#weight' => 100,
];

$form['actions']['submit']['#attributes']['class'] = ['button--next'];
}

/**
* Implements hook_form_FORM_ID_alter() for install_settings_form.
*/
function acquia_drupal_cms_installer_theme_form_install_settings_form_alter(array &$form): void {
$form['help'] = [
'#prefix' => '<p class="cms-installer__subhead">',
'#markup' => t("You don't need to change anything here unless you want to use a different database type."),
'#suffix' => '</p>',
'#weight' => -50,
];
}

/**
* Implements hook_form_FORM_ID_alter() for install_configure_form.
*/
function acquia_drupal_cms_installer_theme_form_install_configure_form_alter(array &$form): void {
$form['#title'] = t('Create your account');

$form['help'] = [
'#prefix' => '<p class="cms-installer__subhead">',
'#markup' => t('Creating an account allows you to log in to your site.'),
'#suffix' => '</p>',
'#weight' => -40,
];

// Use isset() to guard against the possibility that core will change the
// structure of this form in a minor release.
if (isset($form['admin_account']['account']['name'])) {
$form['admin_account']['account']['mail'] += [
'#prefix' => '<div class="cms-installer__form-group">',
'#suffix' => '</div>',
];
}
if (isset($form['admin_account']['account']['pass'])) {
$form['admin_account']['account']['pass'] += [
'#prefix' => '<div class="cms-installer__form-group">',
'#suffix' => '</div>',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#edit-add-ons {
display: flex;
flex-wrap: wrap;
gap: var(--gin-spacing-m);
padding-block: 1px;
}

#edit-add-ons .form-item {
display: inline-block;
margin: 0;
position: relative;
}

#edit-add-ons [type="checkbox"] {
position: absolute;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
inline-size: 1px;
block-size: 1px;
word-wrap: normal;
}

#edit-add-ons label {
display: inline-block;
border: 1.5px solid var(--gin-border-color-form-element);
font-size: var(--gin-font-size-l);
padding: var(--gin-spacing-m);
border-radius: var(--gin-border-m);
font-weight: 600;
line-height: 1;
user-select: none;
margin: 0;
}

#edit-add-ons label:hover {
color: var(--gin-color-primary);
border-color: var(--gin-color-primary);
}

#edit-add-ons :checked + label {
position: relative;
border-color: currentcolor;
}

#edit-add-ons :checked+label:before {
position: absolute;
inset-block-start: 0;
inset-inline-start: 0;
display: block;
inline-size: 1.25rem;
block-size: 1.25rem;
aspect-ratio: 1;
transform: translate(-50%, -50%); /* RTL */
text-align: center;
content: url('../images/check-circle.svg');
background-color: black;
color: white;
border-radius: 50%;
}

@media (forced-colors: active) {
#edit-add-ons :checked+label:before {
display: flex;
align-items: center;
justify-content: center;
content: "✓";
border: solid 2px;
font-weight: bold;
}
}

[dir="rtl"] #edit-add-ons :checked+label:before {
transform: translate(50%, -50%);
}

#edit-add-ons [type="checkbox"]:focus + label {
outline: 3px solid var(--color-focus);
outline-offset: 2px;
}
Loading

0 comments on commit da3cacb

Please sign in to comment.