UpgradeShell.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. <?php
  2. /**
  3. * Upgrade Shell
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package Cake.Console.Command
  16. * @since CakePHP(tm) v 2.0
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('Folder', 'Utility');
  20. /**
  21. * A shell class to help developers upgrade applications to CakePHP 2.0
  22. *
  23. * @package Cake.Console.Command
  24. */
  25. class UpgradeShell extends Shell {
  26. /**
  27. * Files
  28. *
  29. * @var array
  30. */
  31. protected $_files = array();
  32. /**
  33. * Paths
  34. *
  35. * @var array
  36. */
  37. protected $_paths = array();
  38. /**
  39. * Map
  40. *
  41. * @var array
  42. */
  43. protected $_map = array(
  44. 'Controller' => 'Controller',
  45. 'Component' => 'Controller/Component',
  46. 'Model' => 'Model',
  47. 'Behavior' => 'Model/Behavior',
  48. 'Datasource' => 'Model/Datasource',
  49. 'Dbo' => 'Model/Datasource/Database',
  50. 'View' => 'View',
  51. 'Helper' => 'View/Helper',
  52. 'Shell' => 'Console/Command',
  53. 'Task' => 'Console/Command/Task',
  54. 'Case' => 'Test/Case',
  55. 'Fixture' => 'Test/Fixture',
  56. 'Error' => 'Lib/Error',
  57. );
  58. /**
  59. * Shell startup, prints info message about dry run.
  60. *
  61. * @return void
  62. */
  63. public function startup() {
  64. parent::startup();
  65. if ($this->params['dry-run']) {
  66. $this->out(__d('cake_console', '<warning>Dry-run mode enabled!</warning>'), 1, Shell::QUIET);
  67. }
  68. if ($this->params['git'] && !is_dir('.git')) {
  69. $this->out(__d('cake_console', '<warning>No git repository detected!</warning>'), 1, Shell::QUIET);
  70. }
  71. }
  72. /**
  73. * Run all upgrade steps one at a time
  74. *
  75. * @return void
  76. */
  77. public function all() {
  78. foreach($this->OptionParser->subcommands() as $command) {
  79. $name = $command->name();
  80. if ($name === 'all') {
  81. continue;
  82. }
  83. $this->out(__d('cake_console', 'Running %s', $name));
  84. $this->$name();
  85. }
  86. }
  87. /**
  88. * Update tests.
  89. *
  90. * - Update tests class names to FooTest rather than FooTestCase.
  91. *
  92. * @return void
  93. */
  94. public function tests() {
  95. $this->_paths = array(APP . 'tests' . DS);
  96. if (!empty($this->params['plugin'])) {
  97. $this->_paths = App::pluginPath($this->params['plugin']) . 'tests' . DS;
  98. }
  99. $patterns = array(
  100. array(
  101. '*TestCase extends CakeTestCase to *Test extends CakeTestCase',
  102. '/([a-zA-Z]*Test)Case extends CakeTestCase/',
  103. '\1 extends CakeTestCase'
  104. ),
  105. );
  106. $this->_filesRegexpUpdate($patterns);
  107. }
  108. /**
  109. * Move files and folders to their new homes
  110. *
  111. * Moves folders containing files which cannot necessarily be auto-detected (libs and templates)
  112. * and then looks for all php files except vendors, and moves them to where Cake 2.0 expects
  113. * to find them.
  114. *
  115. * @return void
  116. */
  117. public function locations() {
  118. $cwd = getcwd();
  119. if (!empty($this->params['plugin'])) {
  120. chdir(App::pluginPath($this->params['plugin']));
  121. }
  122. if (is_dir('plugins')) {
  123. $Folder = new Folder('plugins');
  124. list($plugins) = $Folder->read();
  125. foreach($plugins as $plugin) {
  126. chdir($cwd . DS . 'plugins' . DS . $plugin);
  127. $this->locations();
  128. }
  129. $this->_files = array();
  130. chdir($cwd);
  131. }
  132. $this->_moveViewFiles();
  133. $moves = array(
  134. 'libs' => 'Lib',
  135. 'tests' => 'Test',
  136. 'Test' . DS . 'cases' => 'Test' . DS . 'Case',
  137. 'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
  138. 'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
  139. );
  140. foreach($moves as $old => $new) {
  141. if (is_dir($old)) {
  142. $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
  143. if (!$this->params['dry-run']) {
  144. if ($this->params['git']) {
  145. exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new));
  146. } else {
  147. $Folder = new Folder($old);
  148. $Folder->move($new);
  149. }
  150. }
  151. }
  152. }
  153. $sourceDirs = array(
  154. '.' => array('recursive' => false),
  155. 'Console',
  156. 'Controller',
  157. 'controllers',
  158. 'Lib' => array('checkFolder' => false),
  159. 'Model',
  160. 'models',
  161. 'Test' => array('regex' => '@class (\S*Test) extends CakeTestCase@'),
  162. 'tests',
  163. 'View',
  164. 'views',
  165. 'vendors/shells',
  166. );
  167. $defaultOptions = array(
  168. 'recursive' => true,
  169. 'checkFolder' => true,
  170. 'regex' => '@class (\S*) .*{@i'
  171. );
  172. foreach($sourceDirs as $dir => $options) {
  173. if (is_numeric($dir)) {
  174. $dir = $options;
  175. $options = array();
  176. }
  177. $options = array_merge($defaultOptions, $options);
  178. $this->_movePhpFiles($dir, $options);
  179. }
  180. }
  181. /**
  182. * Update helpers.
  183. *
  184. * - Converts helpers usage to new format.
  185. *
  186. * @return void
  187. */
  188. public function helpers() {
  189. $this->_paths = array_diff(App::path('views'), App::core('views'));
  190. if (!empty($this->params['plugin'])) {
  191. $this->_paths = array(App::pluginPath($this->params['plugin']) . 'views' . DS);
  192. }
  193. $patterns = array();
  194. $helpers = App::objects('helper');
  195. $plugins = App::objects('plugin');
  196. $pluginHelpers = array();
  197. foreach ($plugins as $plugin) {
  198. $pluginHelpers = array_merge(
  199. $pluginHelpers,
  200. App::objects('helper', App::pluginPath($plugin) . DS . 'views' . DS . 'helpers' . DS, false)
  201. );
  202. }
  203. $helpers = array_merge($pluginHelpers, $helpers);
  204. foreach ($helpers as $helper) {
  205. $oldHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1);
  206. $patterns[] = array(
  207. "\${$oldHelper} to \$this->{$helper}",
  208. "/\\\${$oldHelper}->/",
  209. "\\\$this->{$helper}->"
  210. );
  211. }
  212. $this->_filesRegexpUpdate($patterns);
  213. }
  214. /**
  215. * Update i18n.
  216. *
  217. * - Removes extra true param.
  218. * - Add the echo to __*() calls that didn't need them before.
  219. *
  220. * @return void
  221. */
  222. public function i18n() {
  223. $this->_paths = array(
  224. APP
  225. );
  226. if (!empty($this->params['plugin'])) {
  227. $this->_paths = array(App::pluginPath($this->params['plugin']));
  228. }
  229. $patterns = array(
  230. array(
  231. '<?php __*(*) to <?php echo __*(*)',
  232. '/<\?php\s*(__[a-z]*\(.*?\))/',
  233. '<?php echo \1'
  234. ),
  235. array(
  236. '<?php __*(*, true) to <?php echo __*()',
  237. '/<\?php\s*(__[a-z]*\(.*?)(,\s*true)(\))/',
  238. '<?php echo \1\3'
  239. ),
  240. array('__*(*, true) to __*(*)', '/(__[a-z]*\(.*?)(,\s*true)(\))/', '\1\3')
  241. );
  242. $this->_filesRegexpUpdate($patterns);
  243. }
  244. /**
  245. * Upgrade the removed basics functions.
  246. *
  247. * - a(*) -> array(*)
  248. * - e(*) -> echo *
  249. * - ife(*, *, *) -> !empty(*) ? * : *
  250. * - a(*) -> array(*)
  251. * - r(*, *, *) -> str_replace(*, *, *)
  252. * - up(*) -> strtoupper(*)
  253. * - low(*, *, *) -> strtolower(*)
  254. * - getMicrotime() -> microtime(true)
  255. *
  256. * @return void
  257. */
  258. public function basics() {
  259. $this->_paths = array(
  260. APP
  261. );
  262. if (!empty($this->params['plugin'])) {
  263. $this->_paths = array(App::pluginPath($this->params['plugin']));
  264. }
  265. $patterns = array(
  266. array(
  267. 'a(*) -> array(*)',
  268. '/\ba\((.*)\)/',
  269. 'array(\1)'
  270. ),
  271. array(
  272. 'e(*) -> echo *',
  273. '/\be\((.*)\)/',
  274. 'echo \1'
  275. ),
  276. array(
  277. 'ife(*, *, *) -> !empty(*) ? * : *',
  278. '/ife\((.*), (.*), (.*)\)/',
  279. '!empty(\1) ? \2 : \3'
  280. ),
  281. array(
  282. 'r(*, *, *) -> str_replace(*, *, *)',
  283. '/\br\(/',
  284. 'str_replace('
  285. ),
  286. array(
  287. 'up(*) -> strtoupper(*)',
  288. '/\bup\(/',
  289. 'strtoupper('
  290. ),
  291. array(
  292. 'low(*) -> strtolower(*)',
  293. '/\blow\(/',
  294. 'strtolower('
  295. ),
  296. array(
  297. 'getMicrotime() -> microtime(true)',
  298. '/getMicrotime\(\)/',
  299. 'microtime(true)'
  300. ),
  301. );
  302. $this->_filesRegexpUpdate($patterns);
  303. }
  304. /**
  305. * Update the properties moved to CakeRequest.
  306. *
  307. * @return void
  308. */
  309. public function request() {
  310. $views = array_diff(App::path('views'), App::core('views'));
  311. $controllers = array_diff(App::path('controllers'), App::core('controllers'), array(APP));
  312. $components = array_diff(App::path('components'), App::core('components'));
  313. $this->_paths = array_merge($views, $controllers, $components);
  314. if (!empty($this->params['plugin'])) {
  315. $pluginPath = App::pluginPath($this->params['plugin']);
  316. $this->_paths = array(
  317. $pluginPath . 'controllers' . DS,
  318. $pluginPath . 'controllers' . DS . 'components' .DS,
  319. $pluginPath . 'views' . DS,
  320. );
  321. }
  322. $patterns = array(
  323. array(
  324. '$this->data -> $this->request->data',
  325. '/(\$this->data\b(?!\())/',
  326. '$this->request->data'
  327. ),
  328. array(
  329. '$this->params -> $this->request->params',
  330. '/(\$this->params\b(?!\())/',
  331. '$this->request->params'
  332. ),
  333. array(
  334. '$this->webroot -> $this->request->webroot',
  335. '/(\$this->webroot\b(?!\())/',
  336. '$this->request->webroot'
  337. ),
  338. array(
  339. '$this->base -> $this->request->base',
  340. '/(\$this->base\b(?!\())/',
  341. '$this->request->base'
  342. ),
  343. array(
  344. '$this->here -> $this->request->here',
  345. '/(\$this->here\b(?!\())/',
  346. '$this->request->here'
  347. ),
  348. array(
  349. '$this->action -> $this->request->action',
  350. '/(\$this->action\b(?!\())/',
  351. '$this->request->action'
  352. ),
  353. );
  354. $this->_filesRegexpUpdate($patterns);
  355. }
  356. /**
  357. * Update Configure::read() calls with no params.
  358. *
  359. * @return void
  360. */
  361. public function configure() {
  362. $this->_paths = array(
  363. APP
  364. );
  365. if (!empty($this->params['plugin'])) {
  366. $this->_paths = array(App::pluginPath($this->params['plugin']));
  367. }
  368. $patterns = array(
  369. array(
  370. "Configure::read() -> Configure::read('debug')",
  371. '/Configure::read\(\)/',
  372. 'Configure::read(\'debug\')'
  373. ),
  374. );
  375. $this->_filesRegexpUpdate($patterns);
  376. }
  377. /**
  378. * constants
  379. *
  380. * @return void
  381. */
  382. public function constants() {
  383. $this->_paths = array(
  384. APP
  385. );
  386. if (!empty($this->params['plugin'])) {
  387. $this->_paths = array(App::pluginPath($this->params['plugin']));
  388. }
  389. $patterns = array(
  390. array(
  391. "LIBS -> CAKE",
  392. '/\bLIBS\b/',
  393. 'CAKE'
  394. ),
  395. array(
  396. "CONFIGS -> APP . 'Config' . DS",
  397. '/\bCONFIGS\b/',
  398. 'APP . \'Config\' . DS'
  399. ),
  400. array(
  401. "CONTROLLERS -> APP . 'Controller' . DS",
  402. '/\bCONTROLLERS\b/',
  403. 'APP . \'Controller\' . DS'
  404. ),
  405. array(
  406. "COMPONENTS -> APP . 'Controller' . DS . 'Component' . DS",
  407. '/\bCOMPONENTS\b/',
  408. 'APP . \'Controller\' . DS . \'Component\''
  409. ),
  410. array(
  411. "MODELS -> APP . 'Model' . DS",
  412. '/\bMODELS\b/',
  413. 'APP . \'Model\' . DS'
  414. ),
  415. array(
  416. "BEHAVIORS -> APP . 'Model' . DS . 'Behavior' . DS",
  417. '/\bBEHAVIORS\b/',
  418. 'APP . \'Model\' . DS . \'Behavior\' . DS'
  419. ),
  420. array(
  421. "VIEWS -> APP . 'View' . DS",
  422. '/\bVIEWS\b/',
  423. 'APP . \'View\' . DS'
  424. ),
  425. array(
  426. "HELPERS -> APP . 'View' . DS . 'Helper' . DS",
  427. '/\bHELPERS\b/',
  428. 'APP . \'View\' . DS . \'Helper\' . DS'
  429. ),
  430. array(
  431. "LAYOUTS -> APP . 'View' . DS . 'Layouts' . DS",
  432. '/\bLAYOUTS\b/',
  433. 'APP . \'View\' . DS . \'Layouts\' . DS'
  434. ),
  435. array(
  436. "ELEMENTS -> APP . 'View' . DS . 'Elements' . DS",
  437. '/\bELEMENTS\b/',
  438. 'APP . \'View\' . DS . \'Elements\' . DS'
  439. ),
  440. array(
  441. "CONSOLE_LIBS -> CAKE . 'Console' . DS",
  442. '/\bCONSOLE_LIBS\b/',
  443. 'CAKE . \'Console\' . DS'
  444. ),
  445. array(
  446. "CAKE_TESTS_LIB -> CAKE . 'TestSuite' . DS",
  447. '/\bCAKE_TESTS_LIB\b/',
  448. 'CAKE . \'TestSuite\' . DS'
  449. ),
  450. array(
  451. "CAKE_TESTS -> CAKE . 'Test' . DS",
  452. '/\bCAKE_TESTS\b/',
  453. 'CAKE . \'Test\' . DS'
  454. )
  455. );
  456. $this->_filesRegexpUpdate($patterns);
  457. }
  458. /**
  459. * Update components.
  460. *
  461. * - Make components that extend Object to extend Component.
  462. *
  463. * @return void
  464. */
  465. public function components() {
  466. $this->_paths = App::Path('Controller/Component');
  467. if (!empty($this->params['plugin'])) {
  468. $this->_paths = App::Path('Controller/Component', $this->params['plugin']);
  469. }
  470. $patterns = array(
  471. array(
  472. '*Component extends Object to *Component extends Component',
  473. '/([a-zA-Z]*Component extends) Object/',
  474. '\1 Component'
  475. ),
  476. );
  477. $this->_filesRegexpUpdate($patterns);
  478. }
  479. /**
  480. * Move application views files to where they now should be
  481. *
  482. * Find all view files in the folder and determine where cake expects the file to be
  483. *
  484. * @return void
  485. */
  486. protected function _moveViewFiles() {
  487. if (!is_dir('views')) {
  488. return;
  489. }
  490. $dirs = scandir('views');
  491. foreach ($dirs as $old) {
  492. if (!is_dir('views' . DS . $old) || $old === '.' || $old === '..') {
  493. continue;
  494. }
  495. $new = 'View' . DS . Inflector::camelize($old);
  496. $old = 'views' . DS . $old;
  497. $this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
  498. if (!$this->params['dry-run']) {
  499. if ($this->params['git']) {
  500. exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new));
  501. } else {
  502. $Folder = new Folder($old);
  503. $Folder->move($new);
  504. }
  505. }
  506. }
  507. }
  508. /**
  509. * Move application php files to where they now should be
  510. *
  511. * Find all php files in the folder (honoring recursive) and determine where cake expects the file to be
  512. * If the file is not exactly where cake expects it - move it.
  513. *
  514. * @param mixed $path
  515. * @param mixed $options array(recursive, checkFolder)
  516. * @return void
  517. */
  518. protected function _movePhpFiles($path, $options) {
  519. if (!is_dir($path)) {
  520. return;
  521. }
  522. $paths = $this->_paths;
  523. $this->_paths = array($path);
  524. $this->_files = array();
  525. if ($options['recursive']) {
  526. $this->_findFiles('php');
  527. } else {
  528. $this->_files = scandir($path);
  529. foreach($this->_files as $i => $file) {
  530. if (strlen($file) < 5 || substr($file, -4) !== '.php') {
  531. unset($this->_files[$i]);
  532. }
  533. }
  534. }
  535. $cwd = getcwd();
  536. foreach ($this->_files as &$file) {
  537. $file = $cwd . DS . $file;
  538. $contents = file_get_contents($file);
  539. preg_match($options['regex'], $contents, $match);
  540. if (!$match) {
  541. continue;
  542. }
  543. $class = $match[1];
  544. if (substr($class, 0, 3) === 'Dbo') {
  545. $type = 'Dbo';
  546. } else {
  547. preg_match('@([A-Z][^A-Z]*)$@', $class, $match);
  548. if ($match) {
  549. $type = $match[1];
  550. } else {
  551. $type = 'unknown';
  552. }
  553. }
  554. preg_match('@^.*[\\\/]plugins[\\\/](.*?)[\\\/]@', $file, $match);
  555. $base = $cwd . DS;
  556. $plugin = false;
  557. if ($match) {
  558. $base = $match[0];
  559. $plugin = $match[1];
  560. }
  561. if ($options['checkFolder'] && !empty($this->_map[$type])) {
  562. $folder = str_replace('/', DS, $this->_map[$type]);
  563. $new = $base . $folder . DS . $class . '.php';
  564. } else {
  565. $new = dirname($file) . DS . $class . '.php';
  566. }
  567. if ($file === $new) {
  568. continue;
  569. }
  570. $dir = dirname($new);
  571. if (!is_dir($dir)) {
  572. new Folder($dir, true);
  573. }
  574. $this->out(__d('cake_console', 'Moving %s to %s', $file, $new), 1, Shell::VERBOSE);
  575. if (!$this->params['dry-run']) {
  576. if ($this->params['git']) {
  577. exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($new));
  578. } else {
  579. rename($file, $new);
  580. }
  581. }
  582. }
  583. $this->_paths = $paths;
  584. }
  585. /**
  586. * Updates files based on regular expressions.
  587. *
  588. * @param array $patterns Array of search and replacement patterns.
  589. * @return void
  590. */
  591. protected function _filesRegexpUpdate($patterns) {
  592. $this->_findFiles($this->params['ext']);
  593. foreach ($this->_files as $file) {
  594. $this->out(__d('cake_console', 'Updating %s...', $file), 1, Shell::VERBOSE);
  595. $this->_updateFile($file, $patterns);
  596. }
  597. }
  598. /**
  599. * Searches the paths and finds files based on extension.
  600. *
  601. * @param string $extensions
  602. * @return void
  603. */
  604. protected function _findFiles($extensions = '') {
  605. foreach ($this->_paths as $path) {
  606. if (!is_dir($path)) {
  607. continue;
  608. }
  609. $this->_files = array();
  610. $Iterator = new RegexIterator(
  611. new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)),
  612. '/^.+\.(' . $extensions . ')$/i',
  613. RegexIterator::MATCH
  614. );
  615. foreach ($Iterator as $file) {
  616. if ($file->isFile()) {
  617. $this->_files[] = $file->getPathname();
  618. }
  619. }
  620. }
  621. }
  622. /**
  623. * Update a single file.
  624. *
  625. * @param string $file The file to update
  626. * @param array $patterns The replacement patterns to run.
  627. * @return void
  628. */
  629. protected function _updateFile($file, $patterns) {
  630. $contents = file_get_contents($file);
  631. foreach ($patterns as $pattern) {
  632. $this->out(__d('cake_console', ' * Updating %s', $pattern[0]), 1, Shell::VERBOSE);
  633. $contents = preg_replace($pattern[1], $pattern[2], $contents);
  634. }
  635. $this->out(__d('cake_console', 'Done updating %s', $file), 1);
  636. if (!$this->params['dry-run']) {
  637. file_put_contents($file, $contents);
  638. }
  639. }
  640. /**
  641. * get the option parser
  642. *
  643. * @return ConsoleOptionParser
  644. */
  645. public function getOptionParser() {
  646. $subcommandParser = array(
  647. 'options' => array(
  648. 'plugin' => array(
  649. 'short' => 'p',
  650. 'help' => __d('cake_console', 'The plugin to update. Only the specified plugin will be updated.')
  651. ),
  652. 'ext' => array(
  653. 'short' => 'e',
  654. 'help' => __d('cake_console', 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'),
  655. 'default' => 'php|ctp|thtml|inc|tpl'
  656. ),
  657. 'git' => array(
  658. 'short' => 'g',
  659. 'help' => __d('cake_console', 'Use git command for moving files around.'),
  660. 'boolean' => true
  661. ),
  662. 'dry-run'=> array(
  663. 'short' => 'd',
  664. 'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'),
  665. 'boolean' => true
  666. )
  667. )
  668. );
  669. return parent::getOptionParser()
  670. ->description(__d('cake_console', "A shell to help automate upgrading from CakePHP 1.3 to 2.0. \n" .
  671. "Be sure to have a backup of your application before running these commands."))
  672. ->addSubcommand('all', array(
  673. 'help' => __d('cake_console', 'Run all upgrade commands.'),
  674. 'parser' => $subcommandParser
  675. ))
  676. ->addSubcommand('tests', array(
  677. 'help' => __d('cake_console', 'Update tests class names to FooTest rather than FooTestCase.'),
  678. 'parser' => $subcommandParser
  679. ))
  680. ->addSubcommand('locations', array(
  681. 'help' => __d('cake_console', 'Move files and folders to their new homes.'),
  682. 'parser' => $subcommandParser
  683. ))
  684. ->addSubcommand('i18n', array(
  685. 'help' => __d('cake_console', 'Update the i18n translation method calls.'),
  686. 'parser' => $subcommandParser
  687. ))
  688. ->addSubcommand('helpers', array(
  689. 'help' => __d('cake_console', 'Update calls to helpers.'),
  690. 'parser' => $subcommandParser
  691. ))
  692. ->addSubcommand('basics', array(
  693. 'help' => __d('cake_console', 'Update removed basics functions to PHP native functions.'),
  694. 'parser' => $subcommandParser
  695. ))
  696. ->addSubcommand('request', array(
  697. 'help' => __d('cake_console', 'Update removed request access, and replace with $this->request.'),
  698. 'parser' => $subcommandParser
  699. ))
  700. ->addSubcommand('configure', array(
  701. 'help' => __d('cake_console', "Update Configure::read() to Configure::read('debug')"),
  702. 'parser' => $subcommandParser
  703. ))
  704. ->addSubcommand('constants', array(
  705. 'help' => __d('cake_console', "Replace Obsolete constants"),
  706. 'parser' => $subcommandParser
  707. ))
  708. ->addSubcommand('components', array(
  709. 'help' => __d('cake_console', 'Update components to extend Component class.'),
  710. 'parser' => $subcommandParser
  711. ));
  712. }
  713. }