Making the request method not update things in the models directory. They don't have a request object so those changes will always be wrong.

Adding a dry-run mode and some additional output for it.
Making both the helpers and request tasks hit all the bootstrapped paths.
This commit is contained in:
mark_story 2011-01-01 22:13:45 -05:00
parent 78a376ebc4
commit 814142e3dd

View file

@ -9,6 +9,17 @@ class UpgradeShell extends Shell {
protected $_files = array(); protected $_files = array();
protected $_paths = array(); protected $_paths = array();
/**
* Shell startup, prints info message about dry run.
*
* @return void
*/
function startup() {
parent::startup();
if ($this->params['dry-run']) {
$this->out('<warning>Dry-run mode enabled!</warning>', 1, Shell::QUIET);
}
}
/** /**
* Update helpers. * Update helpers.
* *
@ -17,9 +28,8 @@ class UpgradeShell extends Shell {
* @return void * @return void
*/ */
function helpers() { function helpers() {
$this->_paths = array( $this->_paths = array_diff(App::path('views'), App::core('views'));
VIEWS
);
if (!empty($this->params['plugin'])) { if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin']) . 'views' . DS); $this->_paths = array(App::pluginPath($this->params['plugin']) . 'views' . DS);
} }
@ -147,11 +157,20 @@ class UpgradeShell extends Shell {
* @return void * @return void
*/ */
public function request() { public function request() {
$this->_paths = array( $core = App::core();
APP $views = array_diff(App::path('views'), App::core('views'));
); $controllers = array_diff(App::path('controllers'), App::core('controllers'), array(APP));
$components = array_diff(App::path('components'), App::core('components'));
$this->_paths = array_merge($views, $controllers, $components);
if (!empty($this->params['plugin'])) { if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin'])); $pluginPath = App::pluginPath($this->params['plugin']);
$this->_paths = array(
$pluginPath . 'controllers' . DS,
$pluginPath . 'controllers' . DS . 'components' .DS,
$pluginPath . 'views' . DS,
);
} }
$patterns = array( $patterns = array(
array( array(
@ -263,8 +282,10 @@ class UpgradeShell extends Shell {
} }
$this->out('Done updating ' . $file, 1); $this->out('Done updating ' . $file, 1);
if (!$this->params['dry-run']) {
file_put_contents($file, $contents); file_put_contents($file, $contents);
} }
}
/** /**
* get the option parser * get the option parser
@ -283,6 +304,11 @@ class UpgradeShell extends Shell {
'help' => __('The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'), 'help' => __('The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'),
'default' => 'php|ctp|thtml|inc|tpl' 'default' => 'php|ctp|thtml|inc|tpl'
), ),
'dry-run'=> array(
'short' => 'd',
'help' => __('Dry run the update, no files will actually be modified.'),
'boolean' => true
)
) )
); );