} $client = new Client(); $app = $client->post('apps', array('app' => array('name' => $args[1]))); // Generate security file $dest = Project::root(Project::DIRECTORY_NAME) . '/'; @mkdir($dest, 0777, true); @mkdir($dest . 'config/', 0777, true); @mkdir($dest . 'credentials/', 0777, true); $default_config_files = array('security.yaml', 'packages.yaml', 'schedule.yaml', 'schema.yaml', 'config/config.yaml', 'config/config.environment.yaml'); foreach ($default_config_files as $config_file) { $dest_file = $dest . $config_file; $template = file_get_contents(__DIR__ . '/../../templates/' . $config_file); // replace environment on file if (preg_match('/\\.environment\\./', $dest_file)) { $dest_file = preg_replace('/\\.(environment)\\./', '.' . Project::getEnvironment() . '.', $dest_file); $template = preg_replace('/{{environment}}/', Project::getEnvironment(), $template); } if (!file_exists($dest_file)) { Console::success('create ' . str_replace(Project::root(), "", $dest_file)); file_put_contents($dest_file, $template); } } if (!$args['json']) { Project::createCredentialsDirectory(); foreach ($app->keys as $key) { $credentials = array('app_id' => $key->app_id, 'key' => $key->key, 'type' => $key->type, 'endpoint' => Client::getEndpoint()); $dest_file = Project::getCredentialsPath() . $key->type . '.json'; file_put_contents($dest_file, json_encode($credentials)); Console::success('create ' . str_replace(Project::root(), "", $dest_file)); } Console::output('Application created successfully.');
} Console::loading_output("Deploying..."); $schedule_data = Utils::parse_yaml($root_directory . '/schedule.yaml'); $schedule = $schedule_data && isset($schedule_data['schedule']) ? $schedule_data['schedule'] : array(); // retrieve application config // compatibility with v0.2.x $config = null; if (file_exists($root_directory . '/config.yaml')) { echo "DEPRECATE WARNING: Please move 'hook-ext/config.yaml' file to 'hook-ext/config/config.yaml'." . PHP_EOL; // TODO: remove on v0.4.x $config = Utils::parse_yaml($root_directory . '/config.yaml'); } else { $config = Utils::parse_yaml($root_directory . '/config/config.yaml'); } // try to read environment-specific configuration $environment_config_file = $root_directory . '/config/config.' . Project::getEnvironment() . '.yaml'; if (file_exists($environment_config_file)) { $environment_config = Utils::parse_yaml($environment_config_file); $config = array_replace_recursive($config, $environment_config); } $stats = $client->post('apps/deploy', array('modules' => $module_sync, 'schema' => Utils::parse_yaml($root_directory . '/schema.yaml'), 'schedule' => $schedule, 'config' => $config, 'security' => Utils::parse_yaml($root_directory . '/security.yaml'), 'packages' => Utils::parse_yaml($root_directory . '/packages.yaml'))); // remove auto-generated PHP files if (count($js_converted_modules) > 0) { foreach ($js_converted_modules as $module) { unlink($module); } } if (isset($stats->error)) { Console::error($stats->error); } if (isset($stats->schedule)) {