Exemplo n.º 1
0
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["moveStatic"] = Console::findCommandOption("p|patternsonly") ? false : true;
     $options["noCacheBuster"] = Console::findCommandOption("n|nocache");
     // see if the starterKit flag was passed so you know what dir to watch
     if (Console::findCommandOption("sk")) {
         // load the starterkit watcher
         $w = new Watcher();
         $w->watchStarterKit();
     } else {
         if (Console::findCommandOption("no-procs")) {
             // don't have to worry about loading processes so launch watcher
             // load the generator
             $g = new Generator();
             $g->generate($options);
             // load the watcher
             $w = new Watcher();
             $w->watch($options);
         } else {
             // a vanilla --watch command needs to have a --no-procs version built
             // so we don't get caught in while() loops. re-request the console command
             $commands = array();
             $commands[] = array("command" => $this->build() . " --no-procs", "timeout" => null, "idle" => 600);
             Console::writeInfo("spawning the watch process...");
             $process = new ProcessSpawner();
             $process->spawn($commands);
         }
     }
 }
 public function testGenerate()
 {
     Console::init();
     Config::init(__DIR__ . "/../../../../../..");
     Dispatcher::init();
     $generator = new Generator();
     $generator->generate(['foo' => 'baz']);
     echo '';
 }
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["moveStatic"] = Console::findCommandOption("p|patternsonly") ? false : true;
     $options["noCacheBuster"] = Console::findCommandOption("n|nocache");
     $g = new Generator();
     $g->generate($options);
     $g->printSaying();
 }
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["exportFiles"] = true;
     $options["exportClean"] = Console::findCommandOption("clean");
     $options["moveStatic"] = false;
     FileUtil::cleanExport();
     $g = new Generator();
     $g->generate($options);
     FileUtil::exportStatic();
 }
Exemplo n.º 5
0
 public function run()
 {
     // set-up required vars
     $options = array();
     $options["moveStatic"] = Console::findCommandOption("p|patternsonly") ? false : true;
     $options["noCacheBuster"] = Console::findCommandOption("n|nocache");
     // DEPRECATED
     // $options["autoReload"]    = Console::findCommandOption("r|autoreload");
     // see if the starterKit flag was passed so you know what dir to watch
     if (Console::findCommandOption("sk")) {
         // load the starterkit watcher
         $w = new Watcher();
         $w->watchStarterKit();
     } else {
         // load the generator
         $g = new Generator();
         $g->generate($options);
         // load the watcher
         $w = new Watcher();
         $w->watch($options);
     }
 }
Exemplo n.º 6
0
 /**
  * Updates the Pattern Lab Website and prints the appropriate message
  * @param  {String}       file name to included in the message
  * @param  {String}       a switch for decided which message isn't printed
  *
  * @return {String}       the final message
  */
 private function updateSite($fileName, $message, $verbose = true)
 {
     $watchMessage = "";
     if ($verbose) {
         if ($message == "added") {
             $watchMessage = "<warning>" . $fileName . " was added to Pattern Lab. reload the website to see this change in the navigation...</warning>";
         } elseif ($message == "removed") {
             $watchMessage = "<warning>" . $fileName . " was removed from Pattern Lab. reload the website to see this change reflected in the navigation...</warning>";
         } elseif ($message == "hidden") {
             $watchMessage = "<warning>" . $fileName . " was hidden from Pattern Lab. reload the website to see this change reflected in the navigation...</warning>";
         } else {
             $watchMessage = "<info>" . $fileName . " changed...</info>";
         }
     }
     $options = $this->options;
     $options["watchVerbose"] = $verbose;
     $options["watchMessage"] = $watchMessage;
     $options["moveStatic"] = false;
     // clear the various data stores for re-population
     Data::clear();
     PatternData::clear();
     Annotations::clear();
     $g = new Generator();
     $g->generate($options);
 }
Exemplo n.º 7
0
 /**
  * Ask questions after the create package is done
  * @param  {Object}     a script event object from composer
  */
 public static function postCreateProjectCmd($event)
 {
     // see if there is an extra component
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (isset($extra["patternlab"])) {
         self::init();
         Console::writeLine("");
         // see if we have any starterkits to suggest
         if (isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) {
             $suggestions = $extra["patternlab"]["starterKitSuggestions"];
             // suggest starterkits
             Console::writeInfo("suggested starterkits that work with this edition:", false, true);
             foreach ($suggestions as $i => $suggestion) {
                 // write each suggestion
                 $num = $i + 1;
                 Console::writeLine($num . ": " . $suggestion, true);
             }
             // prompt for input on the suggestions
             Console::writeLine("");
             $prompt = "choose an option or hit return to skip:";
             $options = "(ex. 1)";
             $input = Console::promptInput($prompt, $options);
             $result = (int) $input - 1;
             if (isset($suggestions[$result])) {
                 Console::writeLine("");
                 $f = new Fetch();
                 $result = $f->fetchStarterKit($suggestions[$result]);
                 if ($result) {
                     Console::writeLine("");
                     $g = new Generator();
                     $g->generate(array("foo" => "bar"));
                     Console::writeLine("");
                     Console::writeInfo("type <desc>php core/console --server</desc> to start the built-in server and see Pattern Lab...", false, true);
                 }
             } else {
                 Console::writeWarning("you will need to install a StarterKit before using Pattern Lab...");
             }
         }
     }
 }