Skip to content

Commit f213f0d

Browse files
committed
adding a starterkit suggestion handler
1 parent d0024d9 commit f213f0d

File tree

1 file changed

+48
-23
lines changed

1 file changed

+48
-23
lines changed

src/PatternLab/InstallerUtil.php

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -421,34 +421,59 @@ public static function postPackageUpdate($event) {
421421
*/
422422
public static function postCreateProjectCmd($event) {
423423

424-
print $event->getComposer()->getPackage()->getName();
424+
// see if there is an extra component
425+
$extra = $event->getComposer()->getPackage()->getExtra();
425426

426-
// run the console and config inits
427-
/*self::init();
428-
429-
print_r($event)
430-
if (Config::getOption("patternExtension")) {
427+
if (isset($extra["patternlab"])) {
431428

432-
}
433-
$input = Console::promptInput("Install the base StarterKit for Twig?","(Y/n)");
434-
435-
if ($input == "y") {
436-
$patternEngine = Config::getOption("patternExtension");
437-
$starterkit = "pattern-lab/starterkit-".$patternEngine."-base";
438-
}
439-
440-
if ($starterkit) {
441-
442-
// download the starterkit
443-
$f = new Fetch();
444-
$f->fetchStarterKit($starterkit);
429+
self::init();
430+
Console::writeLine("");
445431

446-
} else if ($input == "n") {
432+
// see if we have any starterkits to suggest
433+
if (isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) {
434+
435+
$suggestions = $extra["patternlab"]["starterKitSuggestions"];
436+
437+
// suggest starterkits
438+
Console::writeLine("suggested StarterKits that work with this edition:");
439+
foreach ($suggestions as $i => $suggestion) {
440+
441+
// write each suggestion
442+
Console::writeLine($i.": ".$suggestion, true);
443+
444+
}
445+
446+
// prompt for input on the suggestions
447+
$prompt = "choose an option or hit return to skip:";
448+
$options = "(ex. 1)";
449+
$input = Console::promptInput($prompt,$options);
450+
451+
if (isset($suggestions[$input])) {
452+
453+
Console::writeLine("");
454+
$f = new Fetch();
455+
$result = $f->fetchStarterKit($suggestions[$input]);
456+
457+
if ($result) {
458+
459+
Console::writeLine("");
460+
$g = new Generator();
461+
$g->generate(array("foo" => "bar"));
462+
463+
Console::writeLine("");
464+
Console::writeInfo("type <desc>php core/console --server</desc> to start the built-in server and see Pattern Lab...", false, true);
465+
466+
}
467+
468+
} else {
469+
470+
Console::writeWarning("you will need to install a StarterKit before using Pattern Lab...");
471+
472+
}
473+
474+
}
447475

448-
} else {
449-
Console::writeWarning("i didn't understand that input. so you can just set that up after the install finishes");
450476
}
451-
*/
452477

453478
}
454479

0 commit comments

Comments
 (0)