Skip to content

Commit 7672acf

Browse files
authored
Fixes site install and improve init (#59)
* Fix load site install services file. * Remove site-path message on generated files. * Auto-detect web-root directory.
1 parent 98b6d48 commit 7672acf

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

src/Bootstrap/DrupalConsoleCore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public function boot()
3737
$loader->load('services.yml');
3838
}
3939

40-
if (file_exists($this->root.DRUPAL_CONSOLE.'/services-drupal-install')) {
40+
if (file_exists($this->root.DRUPAL_CONSOLE.'/services-drupal-install.yml')) {
4141
$loader->load(
42-
$this->root . DRUPAL_CONSOLE . '/services-drupal-install'
42+
$this->root . DRUPAL_CONSOLE . '/services-drupal-install.yml'
4343
);
4444
}
4545

src/Command/InitCommand.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ class InitCommand extends Command
5050
'generate_chain' => false
5151
];
5252

53+
private $webRootDirectories = [
54+
'web',
55+
'docroot'
56+
];
57+
5358
/**
5459
* InitCommand constructor.
5560
* @param ShowFile $showFile
@@ -107,7 +112,13 @@ protected function interact(InputInterface $input, OutputInterface $output)
107112
}
108113

109114
if ($local) {
110-
$this->configParameters['root'] = $io->askEmpty(
115+
$root = null;
116+
foreach($this->webRootDirectories as $webRootDirectory) {
117+
if (!$root && is_dir(getcwd().'/'.$webRootDirectory)) {
118+
$root = $webRootDirectory;
119+
}
120+
}
121+
$this->configParameters['root'] = $root?:$io->askEmpty(
111122
$this->trans('commands.init.questions.root')
112123
);
113124
}
@@ -178,7 +189,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
178189
}
179190

180191
if ($copiedFiles) {
181-
$this->showFile->copiedFiles($io, $copiedFiles);
192+
$this->showFile->copiedFiles($io, $copiedFiles, false);
182193
$io->newLine();
183194
}
184195

src/EventSubscriber/ShowGeneratedFilesListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function showGeneratedFiles(ConsoleTerminateEvent $event)
6060

6161
$files = $this->fileQueue->getFiles();
6262
if ($files) {
63-
$this->showFile->generatedFiles($io, $files);
63+
$this->showFile->generatedFiles($io, $files, false);
6464
}
6565
}
6666

src/Utils/ShowFile.php

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,44 @@ public function __construct(
3434
/**
3535
* @param DrupalStyle $io
3636
* @param string $files
37+
* @param boolean $showPath
3738
*/
38-
public function generatedFiles($io, $files)
39+
public function generatedFiles($io, $files, $showPath = true)
3940
{
41+
$pathKey = null;
42+
$path = null;
43+
if ($showPath){
44+
$pathKey = 'application.user.messages.path';
45+
$path = $this->root;
46+
}
4047
$this->showFiles(
4148
$io,
4249
$files,
4350
'application.messages.files.generated',
44-
'application.site.messages.path',
45-
$this->root
51+
$pathKey,
52+
$path
4653
);
4754
}
4855

4956
/**
5057
* @param DrupalStyle $io
5158
* @param string $files
59+
* @param boolean $showPath
5260
*/
53-
public function copiedFiles($io, $files)
61+
public function copiedFiles($io, $files, $showPath = true)
5462
{
63+
$pathKey = null;
64+
$path = null;
65+
if ($showPath){
66+
$pathKey = 'application.user.messages.path';
67+
$path = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\').'/.console/';
68+
}
5569
$this->showFiles(
5670
$io,
5771
$files,
5872
'application.messages.files.copied',
59-
'application.user.messages.path',
60-
rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\').'/.console/'
73+
$pathKey,
74+
$path
6175
);
6276
}
6377

@@ -76,11 +90,15 @@ private function showFiles($io, $files, $headerKey, $pathKey, $path)
7690

7791
$io->writeln($this->translator->trans($headerKey));
7892

79-
$io->info(
80-
sprintf('%s:', $this->translator->trans($pathKey)),
81-
false
82-
);
83-
$io->comment($path, false);
93+
if ($pathKey) {
94+
$io->info(
95+
sprintf('%s:', $this->translator->trans($pathKey)),
96+
false
97+
);
98+
}
99+
if ($path) {
100+
$io->comment($path, false);
101+
}
84102
$io->newLine();
85103

86104
$index = 1;

0 commit comments

Comments
 (0)