<?php use Client\Client; use Client\Project; return array('arg0' => 'keys', 'command' => 'keys', 'description' => 'List all application keys.', 'run' => function ($args) { $client = new Client(); $keys = $client->get("apps/keys"); $project = Project::getConfig(); if (!$args['json']) { echo "Application name: {$project['name']}" . PHP_EOL; echo "Application keys:" . PHP_EOL; foreach ($keys as $key) { echo "{" . PHP_EOL; echo "\tapp_id: {$key->app_id}" . PHP_EOL; echo "\tkey: " . $key->key . PHP_EOL; echo "\ttype: " . $key->type . PHP_EOL; echo "}" . PHP_EOL; } if (count($keys) > 0) { } } return $keys; });
<?php use Client\Client; use Client\Project; use Client\Console; return array('arg0' => 'modules', 'command' => 'modules', 'description' => 'List all application modules', 'run' => function ($args) { $client = new Client(); $modules = $client->get("apps/modules"); if (!$args['json']) { if ($modules) { echo "Modules: " . PHP_EOL; foreach ($modules as $module) { echo "\t'{$module->name}' ({$module->type}) - LoC: " . substr_count($module->code, "\n") . PHP_EOL; } } else { $project = Project::getConfig(); echo "No modules found for: '{$project['name']}'." . PHP_EOL; } } return $modules; });
<?php use Client\Client; use Client\Project; use Client\Console; use Symfony\Component\Yaml\Yaml; return array('arg0' => 'config', 'command' => 'config', 'description' => 'List all app configurations', 'run' => function ($args) { $client = new Client(); $configs = $client->get("apps/configs"); $project = Project::getConfig(); if (!$args['json']) { foreach ($project as $key => $value) { Console::output($key . ': ' . $value); } Console::output(str_repeat('-', 37)); if ($configs) { print Yaml::dump(json_decode(json_encode($configs), true), PHP_INT_MAX); } else { Console::output("No configurations found for: '{$project['name']}'."); } } return $configs; });
<?php use Client\Client; use Client\Project; use Client\Console; return array('arg0' => 'generate:schema', 'command' => 'generate:schema', 'description' => 'Generate schema definition config.', 'run' => function ($args) use($commands) { $dest = Project::root(Project::DIRECTORY_NAME) . '/schema.yaml'; @mkdir(dirname($dest), 0777, true); $client = new Client(); $client->setRaiseExceptions(false); $cached_schema = $client->get('apps/schema'); $yaml = new Symfony\Component\Yaml\Dumper(); if (file_exists($dest)) { Console::output("You already have a schema.yaml file.\n" . "Your changes will be lost.\n" . "Overwrite? [y/n]"); $overwrite = Console::readline() == 'y'; if (!$overwrite) { throw new Exception("Aborted."); } } // format schema dump before save $schema_dump = ""; if (!empty($cached_schema)) { $schema_dump = str_replace(' ', ' ', $yaml->dump(json_decode(json_encode($cached_schema), true), 3)); $schema_dump = preg_replace('/^([a-z0-9_]+):\\n/m', "\n\$0", $schema_dump); } file_put_contents($dest, $schema_dump . file_get_contents(__DIR__ . '/../../templates/schema.yaml')); echo "Schema dumped at '{$dest}'." . PHP_EOL; if ($editor = getenv('EDITOR')) { $descriptors = array(array('file', '/dev/tty', 'r'), array('file', '/dev/tty', 'w'), array('file', '/dev/tty', 'w')); $process = proc_open("{$editor} {$dest}", $descriptors, $pipes); }
<?php 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)");