Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit fad1d20

Browse files
authored
Fixes #1403: Randomize user 1 name on install. (#1418)
1 parent d47e92e commit fad1d20

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

phing/build.yml

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ docroot: ${repo.root}/docroot
7575

7676
# Drupal Account Credentials. These are used for installing Drupal.
7777
drupal:
78-
account.name: admin
79-
account.password: admin
8078
account.mail: [email protected]
8179
locale: en
8280
local_settings_file: ${docroot}/sites/default/settings/local.settings.php

src/Drush/Command/BltDoctorCommand.php

-23
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ public function checkAll() {
257257
$this->checkDrupalBootstrapped();
258258
$this->checkDrupalInstalled();
259259
$this->checkCaching();
260-
$this->checkNvmExists();
261260
$this->checkDevDesktop();
262261
$this->checkCiConfig();
263262
$this->checkComposer();
@@ -539,28 +538,6 @@ protected function checkDbConnection() {
539538
$this->logOutcome(__FUNCTION__, $outcome, 'error');
540539
}
541540

542-
/**
543-
* Checks that NVM exists.
544-
*
545-
* Note that this does not check if `nvm use` has been invoked for the correct
546-
* node version.
547-
*/
548-
protected function checkNvmExists() {
549-
$home = getenv("HOME");
550-
if (!file_exists("$home/.nvm")) {
551-
$this->logOutcome(__FUNCTION__, [
552-
'NVM does not exist.',
553-
'',
554-
'It is recommended that you use NVM to manage multiple versions of NodeJS on one machine.',
555-
'Instructions for installing NVM can be found at:',
556-
' https://github.com/creationix/nvm#installation',
557-
], 'error');
558-
}
559-
else {
560-
$this->logOutcome(__FUNCTION__, "NVM exists.", 'info');
561-
}
562-
}
563-
564541
/**
565542
* Indicates whether Drupal core files exist in the docroot.
566543
*

src/Robo/Commands/Drupal/DrupalCommand.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Acquia\Blt\Robo\Commands\Drupal;
44

55
use Acquia\Blt\Robo\BltTasks;
6+
use Acquia\Blt\Robo\Common\RandomString;
67

78
/**
89
* Defines commands in the "drupal:*" namespace.
@@ -17,17 +18,27 @@ class DrupalCommand extends BltTasks {
1718
* @validateMySqlAvailable
1819
*
1920
* @return \Robo\Result
21+
* The `drush site-install` command result.
2022
*/
2123
public function install() {
2224

25+
// Generate a random, valid username.
26+
// @see \Drupal\user\Plugin\Validation\Constraint\UserNameConstraintValidator
27+
$username = RandomString::string(10, FALSE,
28+
function ($string) {
29+
return !preg_match('/[^\x{80}-\x{F7} a-z0-9@+_.\'-]/i', $string);
30+
}
31+
);
32+
2333
$task = $this->taskExec('drush site-install')
34+
->detectInteractive()
35+
->printOutput(TRUE)
2436
->dir($this->getConfigValue('docroot'))
2537
->arg($this->getConfigValue('project.profile.name'))
2638
->rawArg("install_configure_form.update_status_module='array(FALSE,FALSE)'")
2739
->option('site-name', $this->getConfigValue('project.human_name'), '=')
2840
->option('site-mail', $this->getConfigValue('drupal.account.mail'), '=')
29-
->option('account-name', $this->getConfigValue('drupal.account.name'), '=')
30-
->option('account-pass', $this->getConfigValue('drupal.account.pass'), '=')
41+
->option('account-name', $username, '=')
3142
->option('account-mail', $this->getConfigValue('drupal.account.mail'), '=')
3243
->option('locale', $this->getConfigValue('drupal.locale'), '=')
3344
->option('yes');

src/Robo/Hooks/ValidateHook.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function validateMySqlAvailable() {
114114
*/
115115
public function validateInsideVm() {
116116
if ($this->getInspector()->isDrupalVmLocallyInitialized() && !$this->getInspector()->isVmCli()) {
117-
throw new \Exception("You must run this command inside Drupal VM, or else do not use Drupal VM at all. Execute `vagrant ssh`, then try again.");
117+
throw new \Exception("You must run this command inside Drupal VM, or else do not use Drupal VM at all. Execute `vagrant ssh` and then execute the command, or else change drush.aliases.local in blt/project.local.yml.");
118118
}
119119
}
120120

0 commit comments

Comments
 (0)