Skip to content

Commit f7802a4

Browse files
authored
Merge pull request #139 from Chi-teck/issue-119
Single Directory Component generator refers to metadata.json
2 parents 2756528 + 31711a6 commit f7802a4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Command/SingleDirectoryComponent.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private function askQuestions(array &$vars): void {
9090
if ($ir->confirm('Needs component props?')) {
9191
$vars['component_props'] = [];
9292
do {
93-
$prop = $this->askProp($ir);
93+
$prop = $this->askProp($vars, $ir);
9494
$vars['component_props'][] = $prop;
9595
} while ($ir->confirm('Add another prop?'));
9696
}
@@ -161,10 +161,13 @@ private function askLibrary(): ?string {
161161
/**
162162
* Asks for multiple questions to define a prop and its schema.
163163
*
164+
* @psalm-param array{component_machine_name: mixed, ...<array-key, mixed>} $vars
165+
* The answers to the CLI questions.
166+
*
164167
* @return array
165168
* The prop data, if any.
166169
*/
167-
protected function askProp(Interviewer $ir): array {
170+
protected function askProp(array $vars, Interviewer $ir): array {
168171
$prop = [];
169172
$prop['title'] = $ir->ask('Prop title', '', new Required());
170173
$default = Utils::human2machine($prop['title']);
@@ -180,7 +183,10 @@ protected function askProp(Interviewer $ir): array {
180183
];
181184
$prop['type'] = $ir->choice('Prop type', $choices, 'String');
182185
if (!\in_array($prop['type'], ['string', 'number', 'boolean'])) {
183-
$this->io()->warning('Unable to generate full schema for ' . $prop['type'] . '. Please edit metadata.json after generation.');
186+
/** @psalm-var string $type */
187+
$type = $prop['type'];
188+
$component_schema_name = $vars['component_machine_name'] . '.component.yml';
189+
$this->io()->warning(\sprintf('Unable to generate full schema for %s. Please edit %s after generation.', $type, $component_schema_name));
184190
}
185191
return $prop;
186192
}

0 commit comments

Comments
 (0)