コード例 #1
0
ファイル: test-environment.php プロジェクト: sammys/terminus
 /**
  * @vcr site_deploy
  */
 public function testGetParentEnvironment()
 {
     logInWithBehatCredentials();
     $site = $this->sites->get('behat-tests');
     $test_env = $site->environments->get('test');
     $dev_env = $test_env->getParentEnvironment();
     $this->assertEquals($dev_env->get('id'), 'dev');
     setDummyCredentials();
 }
コード例 #2
0
ファイル: wp.php プロジェクト: nataliejeremy/cli
 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional WP-CLI flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         throw new TerminusException("Command could not be completed. Unknown site specified.");
     }
     # see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "******";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}=" . escapeshellarg($v) . ' ';
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info("Running wp {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $this->send_command($server, 'wp', $args, $assoc_args);
 }
コード例 #3
0
ファイル: WpCommand.php プロジェクト: Zacker/cli
 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional WP-CLI flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $command = implode($args, ' ');
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     /**
      * See https://github.com/pantheon-systems/titan-mt/blob/master/..
      *  ..dashboardng/app/workshops/site/models/environment.coffee
      */
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     // Sanitize assoc args so we don't try to pass our own flags.
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     // Create user-friendly output
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}=" . escapeshellarg($v) . ' ';
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info('Running wp {cmd} {flags} on {site}-{env}', array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'wp', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
コード例 #4
0
ファイル: drush.php プロジェクト: nataliejeremy/cli
 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         throw new TerminusException("Command could not be completed. Unknown site specified.");
     }
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "******";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $this->send_command($server, 'drush', $args, $assoc_args);
 }
コード例 #5
0
ファイル: DrushCommand.php プロジェクト: 4aficiona2/cli
 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI command you intend to run, with its arguments
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = array_pop($args);
     $this->checkCommand($command);
     $sites = new Sites();
     $assoc_args['site'] = Input::sitename($assoc_args);
     $site = $sites->get($assoc_args['site']);
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $assoc_args['env'] = $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
         $assoc_args['pipe'] = 1;
     }
     $this->log()->info("Running drush {cmd} on {site}-{env}", array('cmd' => $command, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand(array('server' => $server, 'remote_exec' => 'drush', 'command' => $command));
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
コード例 #6
0
ファイル: WpCommand.php プロジェクト: 4aficiona2/cli
 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI command you intend to run with its arguments, in quotes
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = array_pop($args);
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     $environment = Input::env(array('args' => $assoc_args, 'site' => $site));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     /**
      * See https://github.com/pantheon-systems/titan-mt/blob/master/..
      *  ..dashboardng/app/workshops/site/models/environment.coffee
      */
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     $this->log()->info('Running wp {cmd} on {site}-{env}', array('cmd' => $command, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand(array('server' => $server, 'remote_exec' => 'wp', 'command' => $command));
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
コード例 #7
0
ファイル: drush.php プロジェクト: RobLoach/cli
 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = implode($args, ' ');
     $this->checkCommand($command);
     $sites = new Sites();
     $assoc_args['site'] = Input::sitename($assoc_args);
     $site = $sites->get($assoc_args['site']);
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $assoc_args['env'] = $environment = Input::env($assoc_args);
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     if (isset($assoc_args['site'])) {
         unset($assoc_args['site']);
     }
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
         $assoc_args['pipe'] = 1;
     }
     $this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'drush', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
コード例 #8
0
ファイル: CommandWithSSH.php プロジェクト: sammys/terminus
 /**
  * Parent function to SSH-based command invocations
  *
  * @param string[] $args       Command(s) given in the command line
  * @param string[] $assoc_args Arguments and flags passed into the former
  * @return array Elements as follow:
  *         Site   site    Site being invoked
  *         string env_id  Name of the environment being invoked
  *         string command Command to run remotely
  *         string server  Server connection info
  */
 protected function getElements($args, $assoc_args)
 {
     $this->ensureQuotation($args, $assoc_args);
     $command = array_pop($args);
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get($this->input()->siteName(array('args' => $assoc_args)));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $env_id = $this->input()->env(array('args' => $assoc_args, 'site' => $site));
     if (!in_array($env_id, ['test', 'live'])) {
         $this->checkConnectionMode($site->environments->get($env_id));
     }
     $elements = array('site' => $site, 'env_id' => $env_id, 'command' => $command, 'server' => $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $env_id)));
     return $elements;
 }