protected function starterKitSuggestions() { Console::writeLine(""); $composerPath = Config::getOption("baseDir") . "/composer.json"; if (file_exists($composerPath)) { $json = file_get_contents($composerPath); $data = json_decode($json, true); if ($jsonErrorMessage = JSON::hasError()) { JSON::lastErrorMsg(Console::getHumanReadablePath($oldStyleAnnotationsPath), $jsonErrorMessage, $data); } if (isset($data["extra"]) && isset($data["extra"]["patternlab"]) && isset($data["extra"]["patternlab"]["starterKitSuggestions"])) { $starterKitSuggestions = $data["extra"]["patternlab"]["starterKitSuggestions"]; Console::writeInfo("suggested starterkits that work with this edition:", false, true); foreach ($starterKitSuggestions as $i => $suggestion) { $num = $i + 1; Console::writeLine($num . ": " . $suggestion, true); } // hack around installer util feature in Console::promptInput InstallerUtil::$isInteractive = true; // prompt for input on the suggestions Console::writeLine(""); $prompt = "choose an option or hit return to cancel:"; $options = "(ex. 1)"; $input = Console::promptInput($prompt, $options, "1"); $result = (int) $input - 1; if (isset($starterKitSuggestions[$result])) { Console::writeLine(""); $f = new Fetch(); $result = $f->fetchStarterKit($starterKitSuggestions[$result]); } } else { Console::writeWarning("this edition has no starterkits to suggested...", false, true); } } else { Console::writeError("can't find composer.json to get suggestions...", false, true); } }
protected function starterKitPathPrompt() { // need to figure this out long-term InstallerUtil::$isInteractive = true; $input = Console::promptInput("Tell me the path to the starterkit you want to watch.", "e.g. vendor/pattern-lab/starterkit-mustache-demo/dist", "baz", false); // set-up the full starterkit path $starterKitPath = Config::getOption("baseDir") . $input; if (!is_dir($starterKitPath)) { Console::writeWarning("that doesn't seem to be a real directory. let's try again..."); $starterKitPath = $this->starterKitPathPrompt(); } return $starterKitPath; }