Skip to content

Commit 47ebada

Browse files
committed
add interactive menu
1 parent fa6f1a6 commit 47ebada

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

src/Maker/MakeScaffold.php

+40-5
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,47 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
100100
return;
101101
}
102102

103-
$availableScaffolds = array_combine(
104-
array_keys($this->availableScaffolds()),
105-
array_map(fn (array $scaffold) => $scaffold['description'], $this->availableScaffolds())
106-
);
103+
while (true) {
104+
$availableScaffolds = array_combine(
105+
array_keys($this->availableScaffolds()),
106+
array_map(fn (array $scaffold) => $scaffold['description'], $this->availableScaffolds())
107+
);
108+
109+
$name = $io->choice('Available scaffolds', $availableScaffolds);
110+
$scaffold = $this->availableScaffolds()[$name];
111+
112+
$io->title($name);
113+
$io->text($scaffold['description']);
114+
$io->newLine();
115+
116+
if ($scaffold['dependents'] ?? []) {
117+
$io->text('This scaffold will also install the following scaffolds:');
118+
$io->newLine();
119+
$io->listing($scaffold['dependents']);
120+
}
121+
122+
if ($scaffold['packages'] ?? []) {
123+
$io->text('This scaffold will install the following composer packages:');
124+
$io->newLine();
125+
$io->listing(\array_keys($scaffold['packages']));
126+
}
107127

108-
$input->setArgument('name', [$io->choice('Available scaffolds', $availableScaffolds)]);
128+
if ($scaffold['js_packages'] ?? []) {
129+
$io->text('This scaffold will install the following node packages:');
130+
$io->newLine();
131+
$io->listing(\array_keys($scaffold['js_packages']));
132+
}
133+
134+
if (!$io->confirm("Would your like to create the \"{$name}\" scaffold?")) {
135+
$io->text('Going back to main menu...');
136+
137+
continue;
138+
}
139+
140+
$input->setArgument('name', [$name]);
141+
142+
return;
143+
}
109144
}
110145

111146
private function generateScaffold(string $name, ConsoleStyle $io): void

0 commit comments

Comments
 (0)