Skip to content

Commit 1c02ca2

Browse files
committed
A little more refactoring and cleanup
1 parent 5ffb405 commit 1c02ca2

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

console/create.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,32 +236,33 @@ private function check_dependencies(array $dependencies): bool
236236
return true;
237237
}
238238

239-
private const GITHUB_ACTIONS_TYPES = [
240-
0 => ['githubactions' => false, 'githubactions_custom' => false], // No
241-
1 => ['githubactions' => true, 'githubactions_custom' => false], // Reusable
242-
2 => ['githubactions' => false, 'githubactions_custom' => true], // Standalone
243-
];
244-
245239
/**
246240
* Handle GitHub Actions specific logic
247241
*/
248242
private function handle_github_actions(): void
249243
{
250-
$questionText = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON');
244+
// Lookup table of GitHub Action component settings
245+
$github_actions_types = [
246+
0 => ['githubactions' => false, 'githubactions_custom' => false], // No (default)
247+
1 => ['githubactions' => true, 'githubactions_custom' => false], // Reusable
248+
2 => ['githubactions' => false, 'githubactions_custom' => true], // Standalone
249+
];
250+
251+
$question_text = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON');
251252
$choices = [];
252-
foreach (array_keys(self::GITHUB_ACTIONS_TYPES) as $i)
253+
foreach (array_keys($github_actions_types) as $i)
253254
{
254255
$choices[] = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', $i);
255256
}
256257

257-
$question = new ChoiceQuestion($questionText, $choices, 0);
258+
$question = new ChoiceQuestion($question_text, $choices, 0);
258259
$choice = $this->helper->ask($this->input, $this->output, $question);
259260
$index = array_search($choice, $choices, true);
260261

261-
$componentSettings = self::GITHUB_ACTIONS_TYPES[$index] ?? self::GITHUB_ACTIONS_TYPES[0];
262+
$component_settings = $github_actions_types[$index] ?? $github_actions_types[0];
262263
$this->data['components'] = array_merge(
263264
$this->data['components'] ?? [],
264-
$componentSettings
265+
$component_settings
265266
);
266267
}
267268
}

tests/console/create_test.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public function setUp(): void
9292
'group' => 'TEST_DEPLOY',
9393
],
9494
'githubactions' => [
95+
'default' => false,
96+
'dependencies' => ['tests'],
97+
'files' => ['.github/workflows/tests.yml'],
98+
'group' => 'TEST_DEPLOY',
99+
],
100+
'githubactions_custom' => [
95101
'default' => false,
96102
'dependencies' => [],
97103
'files' => ['.github/workflows/tests.yml'],
@@ -185,6 +191,7 @@ public function get_questions()
185191
// 'SKELETON_QUESTION_COMPONENT_PERMISSIONS' => 'y',
186192
'SKELETON_QUESTION_COMPONENT_TESTS' => 'y',
187193
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 0,
194+
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM' => null,
188195
// 'SKELETON_QUESTION_COMPONENT_BUILD' => 'y',
189196
];
190197
}

0 commit comments

Comments
 (0)