<?php use Client\Utils; use Client\Client; use Client\Project; use Client\Console; return array('arg0' => 'db:seed', 'command' => 'db:seed [<seed-file>]', 'description' => 'Seed collections from YAML files.', 'run' => function ($args) use($commands) { $seed_file = '*.yaml'; if ($args[1] !== null) { $seed_file = $args[1] . '.yaml'; } $client = new Client(); foreach (Utils::glob(Project::root(Project::DIRECTORY_NAME) . '/seeds/' . $seed_file) as $yaml_file) { $collection = basename($yaml_file, '.yaml'); $parser = new Symfony\Component\Yaml\Parser(); $options = $parser->parse(file_get_contents($yaml_file)); if (isset($options['truncate']) && $options['truncate']) { echo "Truncating '{$collection}'... "; try { $truncate = $client->delete('collection/' . $collection); if (count($truncate) > 0) { echo "Success."; } } catch (Exception $e) { echo "Failed."; } echo PHP_EOL; } if (isset($options['data']) && $options['data']) { $current_row = 0; $total_rows = count($options['data']);
use Client\Console; use Client\Client; use Client\Project; use Client\Utils; use Carbon\Carbon; return array('arg0' => 'deploy', 'command' => 'deploy', 'description' => 'Deploy ext directory.', 'run' => function ($args) use($commands) { $client = new Client(); Console::loading_output("Retrieving remote data..."); $deployed = $client->get('apps/deploy'); $root_directory = Project::root(Project::DIRECTORY_NAME); $js_converted_modules = array(); // modules $local_modules = array(); $module_types = array('observers', 'routes', 'templates', 'channels'); foreach ($module_types as $module_type) { foreach (Utils::glob($root_directory . '/' . $module_type . '/*') as $module) { if (!is_file($module)) { continue; } $extension = pathinfo($module, PATHINFO_EXTENSION); if ($extension == "js") { $javascript_module = $module; $module = preg_replace('/\\.js$/', '.php', $module); array_push($js_converted_modules, $module); // keep track for removal // module may already exists due error on previous upload. // ask user to prevent overwriting some manually added .php file if (file_exists($module)) { Console::output("Module '" . basename($module) . "' already exists.\nDo you want to overwrite with converted '" . basename($javascript_module) . "' version?\n(y/n)"); $handle = popen("read; echo \$REPLY", "r"); $input = strtolower(trim(fgets($handle, 100)));