From 53a1663b9656ecd5ab7fdd7278544e1e4cf82cd9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 17 Oct 2010 19:01:44 -0400 Subject: [PATCH] Adding console dir to skel. Updating project task to test for directories and files in a more readable way. --- cake/console/shells/tasks/project.php | 3 + cake/console/templates/skel/console/cake | 26 ++++++ cake/console/templates/skel/console/cake.bat | 33 ++++++++ cake/console/templates/skel/console/cake.php | 25 ++++++ .../groups => console/shells/tasks}/empty | 0 .../skel/vendors/{shells/tasks => }/empty | 0 .../console/shells/tasks/project.test.php | 83 ++++++++++--------- 7 files changed, 129 insertions(+), 41 deletions(-) create mode 100644 cake/console/templates/skel/console/cake create mode 100644 cake/console/templates/skel/console/cake.bat create mode 100644 cake/console/templates/skel/console/cake.php rename cake/console/templates/skel/{tests/groups => console/shells/tasks}/empty (100%) rename cake/console/templates/skel/vendors/{shells/tasks => }/empty (100%) diff --git a/cake/console/shells/tasks/project.php b/cake/console/shells/tasks/project.php index 065cc912c7e..41150f77cb7 100644 --- a/cake/console/shells/tasks/project.php +++ b/cake/console/shells/tasks/project.php @@ -154,6 +154,7 @@ function bake($path, $skel = null, $skip = array('empty')) { if (!empty($this->params['empty'])) { $skip = array(); } + if ($Folder->copy(array('to' => $path, 'skip' => $skip))) { $this->hr(); $this->out(sprintf(__('Created: %s in %s'), $app, $path)); @@ -348,6 +349,8 @@ public function getOptionParser() { __('Generate a new CakePHP project skeleton.') )->addArgument('name', array( 'help' => __('Application directory to make, if it starts with "/" the path is absolute.') + ))->addOption('empty', array( + 'help' => __('Create empty files in each of the directories. Good if you are using git') )); } diff --git a/cake/console/templates/skel/console/cake b/cake/console/templates/skel/console/cake new file mode 100644 index 00000000000..d4d067d59bc --- /dev/null +++ b/cake/console/templates/skel/console/cake @@ -0,0 +1,26 @@ +#!/bin/bash +################################################################################ +# +# Bake is a shell script for running CakePHP bake script +# PHP 5 +# +# CakePHP(tm) : Rapid Development Framework (http://cakephp.org) +# Copyright 2005-2010, Cake Software Foundation, Inc. +# +# Licensed under The MIT License +# Redistributions of files must retain the above copyright notice. +# +# @copyright Copyright 2005-2010, Cake Software Foundation, Inc. +# @link http://cakephp.org CakePHP(tm) Project +# @package cake +# @subpackage cake.app.console +# @since CakePHP(tm) v 2.0 +# @license MIT License (http://www.opensource.org/licenses/mit-license.php) +# +################################################################################ +LIB=${0/%cake/} +APP=`pwd` + +exec php -q ${LIB}cake.php -working "${APP}" "$@" + +exit; \ No newline at end of file diff --git a/cake/console/templates/skel/console/cake.bat b/cake/console/templates/skel/console/cake.bat new file mode 100644 index 00000000000..84ed04a4f95 --- /dev/null +++ b/cake/console/templates/skel/console/cake.bat @@ -0,0 +1,33 @@ +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Bake is a shell script for running CakePHP bake script +:: PHP 5 +:: +:: CakePHP(tm) : Rapid Development Framework (http://cakephp.org) +:: Copyright 2005-2010, Cake Software Foundation, Inc. +:: +:: Licensed under The MIT License +:: Redistributions of files must retain the above copyright notice. +:: +:: @copyright Copyright 2005-2010, Cake Software Foundation, Inc. +:: @link http://cakephp.org CakePHP(tm) Project +:: @package cake +:: @subpackage cake.app.console +:: @since CakePHP(tm) v 2.0 +:: @license MIT License (http://www.opensource.org/licenses/mit-license.php) +:: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: In order for this script to work as intended, the cake\console\ folder must be in your PATH + +@echo. +@echo off + +SET app=%0 +SET lib=%~dp0 + +php -q "%lib%cake.php" -working "%CD%" %* + +echo. + +exit /B %ERRORLEVEL% \ No newline at end of file diff --git a/cake/console/templates/skel/console/cake.php b/cake/console/templates/skel/console/cake.php new file mode 100644 index 00000000000..5a90d8dec90 --- /dev/null +++ b/cake/console/templates/skel/console/cake.php @@ -0,0 +1,25 @@ +#!/usr/bin/php -q +_setupTestProject(); - $path = $this->Task->path . 'bake_test_app'; + $this->assertTrue(is_dir($path), 'No project dir %s'); - $this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s'); - $this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s'); - $this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s'); - $this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s'); - $this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s'); + $dirs = array( + 'config', + 'config' . DS . 'schema', + 'console', + 'console' . DS . 'shells', + 'console' . DS . 'shells' . DS . 'tasks', + 'controllers', + 'models', + 'views', + 'views' . DS . 'helpers', + 'tests', + 'tests' . DS . 'cases', + 'tests' . DS . 'cases' . DS . 'models', + 'tests' . DS . 'cases', + 'tests' . DS . 'fixtures', + 'tmp', + 'webroot', + 'webroot' . DS . 'js', + 'webroot' . DS . 'css', + ); + foreach ($dirs as $dir) { + $this->assertTrue(is_dir($path . DS . $dir), 'Missing ' . $dir); + } } /** @@ -107,36 +121,24 @@ public function testBakeEmptyFlag() { $this->Task->params['empty'] = true; $this->_setupTestProject(); $path = $this->Task->path . 'bake_test_app'; - $this->assertTrue(is_dir($path), 'No project dir %s'); - $this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s'); - $this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s'); - $this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s'); - $this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s'); - $this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s'); - - $this->assertTrue(is_file($path . DS . 'controllers' . DS .'components' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'locale' . DS . 'eng' . DS . 'LC_MESSAGES' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'models' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'models' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'plugins' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'components' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'controllers' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'shells' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'views' . DS . 'errors' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'views' . DS . 'scaffolds' . DS . 'empty'), 'No empty file in dir %s'); - $this->assertTrue(is_file($path . DS . 'webroot' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s'); + + $empty = array( + 'console' . DS . 'shells' . DS . 'tasks', + 'controllers' . DS . 'components', + 'models' . DS . 'behaviors', + 'views' . DS . 'helpers', + 'views' . DS . 'errors', + 'views' . DS . 'scaffolds', + 'tests' . DS . 'cases' . DS . 'models', + 'tests' . DS . 'cases' . DS . 'controllers', + 'tests' . DS . 'cases' . DS . 'helpers', + 'tests' . DS . 'fixtures', + 'webroot' . DS . 'js' + ); + + foreach ($empty as $dir) { + $this->assertTrue(is_file($path . DS . $dir . DS . 'empty'), 'Missing empty file in ' . $dir); + } } /** @@ -272,7 +274,6 @@ public function testExecute() { $this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s'); $this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s'); $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s'); - $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s'); $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s'); } }