@@ -361,7 +361,6 @@ public function backup($args, $assoc_args) {
361361 case 'create ' :
362362 $ type ='backup ' ;
363363 $ path = sprintf ('environments/%s/backups/create ' , $ env );
364- $ site_id = $ this ->getSiteId ( $ assoc_args ['site ' ] );
365364
366365 $ data = array (
367366 'entry_type ' => $ type ,
@@ -374,7 +373,7 @@ public function backup($args, $assoc_args) {
374373 'body ' => json_encode ($ data ) ,
375374 'headers ' => array ('Content-type ' =>'application/json ' )
376375 );
377- $ response = \Terminus_Command::request ( "sites " , $ site_id , $ path , 'POST ' , $ OPTIONS );
376+ $ response = \Terminus_Command::request ( "sites " , $ site -> getId () , $ path , 'POST ' , $ OPTIONS );
378377
379378 if ( @$ response ['data ' ]->id ) {
380379 $ workflow_id = $ response ['data ' ]->id ;
@@ -432,7 +431,8 @@ public function backup($args, $assoc_args) {
432431 * @subcommand clone-env
433432 */
434433 public function clone_env ($ args , $ assoc_args ) {
435- $ site_id = $ this ->getSiteId ($ assoc_args ['site ' ]);
434+ $ site = SiteFactory::instance ($ assoc_args ['site ' ]);
435+ $ site_id = $ site ->getId ();
436436 $ from_env = $ this ->getValidEnv ($ assoc_args ['site ' ], @$ assoc_args ['from-env ' ], "Choose environment you want to clone from " );
437437 $ to_env = $ this ->getValidEnv ($ assoc_args ['site ' ], @$ assoc_args ['to-env ' ], "Choose environment you want to clone to " );
438438
@@ -503,7 +503,8 @@ private function cloneObject($to_env, $from_env, $site_id, $object_type) {
503503 public function create_env ($ args , $ assoc_args ) {
504504 Terminus::error ("Feature currently unavailable. Please create environments in you pantheon dashboard at http://dashboard.getpantheon.com. " );
505505 $ env = $ this ->getValidEnv ($ assoc_args ['site ' ], @$ assoc_args ['env ' ]);
506- $ site_id = $ this ->getSiteId ($ assoc_args ['site ' ]);
506+ $ site = SiteFactory::instance ($ assoc_args ['site ' ]);
507+ $ site_id = $ site ->getId ();
507508 if ($ this ->envExists ($ site_id ,$ env )) {
508509 \Terminus::error ("The %s environment already exists " , array ($ env ));
509510 }
@@ -537,7 +538,7 @@ public function create_env($args, $assoc_args) {
537538 */
538539 public function deploy ($ args , $ assoc_args ) {
539540 $ env = $ this ->getValidEnv (@$ assoc_args ['site ' ], @$ assoc_args ['env ' ], "Select environment to deploy to " );
540-
541+ $ site = SiteFactory:: instance ( $ assoc_args [ ' site ' ]);
541542 $ cc = $ update = 0 ;
542543 if (array_key_exists ('cc ' ,$ assoc_args )) {
543544 $ cc = 1 ;
@@ -550,7 +551,7 @@ public function deploy($args, $assoc_args) {
550551 'update ' => $ update ,
551552 'cc ' => $ cc
552553 );
553- $ site_id = $ this -> getSiteId ( $ assoc_args [ ' site ' ] );
554+ $ site_id = $ site -> getId ( );
554555 $ path = sprintf ('environments/%s/code?%s ' , $ env , http_build_query ($ params ));
555556 $ response = \Terminus_Command::request ('sites ' , $ site_id , $ path , 'POST ' );
556557 $ result = $ this ->waitOnWorkflow ('sites ' , $ site_id , $ response ['data ' ]->id );
@@ -1027,6 +1028,9 @@ public function upstream_info($args, $assoc_args) {
10271028 * [--apply-to=<env>]
10281029 * : A flag to apply to a specified environment
10291030 *
1031+ * [--update]
1032+ * : Do update on dev env
1033+ *
10301034 * @subcommand upstream-updates
10311035 */
10321036 public function upstream_updates ($ args , $ assoc_args ) {
@@ -1044,7 +1048,7 @@ public function upstream_updates($args, $assoc_args) {
10441048 }
10451049
10461050 $ this ->_constructTableForResponse ($ data , array ('Environment ' ,'Status ' ) );
1047- if (empty ($ upstream ->update_log )) Terminus::success ("No updates to show " );
1051+ if (! isset ( $ upstream ) OR empty (@ $ upstream ->update_log )) Terminus::success ("No updates to show " );
10481052 $ upstreams = (array ) $ upstream ->update_log ;
10491053 if (!empty ($ upstreams )) {
10501054 $ data = array ();
@@ -1060,11 +1064,15 @@ public function upstream_updates($args, $assoc_args) {
10601064 }
10611065 }
10621066
1063- if (isset ($ assoc_args ['apply-to ' ] )) {
1064- $ env = $ this -> getValidEnv ( $ site -> getName (), $ assoc_args [ ' apply-to ' ]) ;
1065- Terminus::confirm (sprintf ("Are you sure you want to apply the upstream updates to %s:%s " , $ site ->getName (), $ env ));
1067+ if (isset ($ assoc_args ['update ' ]) AND ! empty (@ $ upstream -> update_log )) {
1068+ $ env = ' dev ' ;
1069+ Terminus::confirm (sprintf ("Are you sure you want to apply the upstream updates to %s-dev " , $ site ->getName (), $ env ));
10661070 $ response = $ site ->applyUpstreamUpdates ($ env );
1067- $ this ->waitOnWorkflow ('sites ' , $ site ->getId (), $ response ->id );
1071+ if (@$ response ->id ) {
1072+ $ this ->waitOnWorkflow ('sites ' , $ site ->getId (), $ response ->id );
1073+ } else {
1074+ Terminus::success ("Updates applied " );
1075+ }
10681076 }
10691077
10701078 }
0 commit comments