Author: lombardot Date: 2010-09-15 17:54:59 +0200 (Wed, 15 Sep 2010) New Revision: 30913
Added: plugins/sfPackageMaker2Plugin/branches/ plugins/sfPackageMaker2Plugin/tags/ plugins/sfPackageMaker2Plugin/trunk/ plugins/sfPackageMaker2Plugin/trunk/LICENSE plugins/sfPackageMaker2Plugin/trunk/README plugins/sfPackageMaker2Plugin/trunk/lib/ plugins/sfPackageMaker2Plugin/trunk/lib/task/ plugins/sfPackageMaker2Plugin/trunk/lib/task/sfPluginPackageTask.class.php plugins/sfPackageMaker2Plugin/trunk/package-skeleton.xml plugins/sfPackageMaker2Plugin/trunk/package.xml Log: [sfPackageMaker2Plugin] lombardot initial commit Added: plugins/sfPackageMaker2Plugin/trunk/LICENSE =================================================================== --- plugins/sfPackageMaker2Plugin/trunk/LICENSE (rev 0) +++ plugins/sfPackageMaker2Plugin/trunk/LICENSE 2010-09-15 15:54:59 UTC (rev 30913) @@ -0,0 +1 @@ +MIT http://www.symfony-project.com/license \ No newline at end of file Added: plugins/sfPackageMaker2Plugin/trunk/README =================================================================== --- plugins/sfPackageMaker2Plugin/trunk/README (rev 0) +++ plugins/sfPackageMaker2Plugin/trunk/README 2010-09-15 15:54:59 UTC (rev 30913) @@ -0,0 +1,84 @@ +== sfPackageMakerPlugin == + + === Description === + +This plugin will help you to create a package by listing all the file in your +plugin directory. + +Take the time to read all the options, like that you could manage automaticaly the xml changelog only +using the task. + + === How To Install === + + {{{ + + ./symfony plugin:install sfPackageMakerPlugin --version="0.2" + ./symfony cc + + }}} + + === When you create your plugin === + + * Copy the package-skelton.xml to your sf_plugins_dir + * Rename it with this syntax package-*YOUR_PLUGIN_NAME*.xml + * In the file change the bloc <lead></lead> And all the author bloc + * Set a summary and a description + * set also the bloc <dependencies> + + *WARNING* If you have forgot to create the README and the LICENSE files, + the task will automatically add this files + + === The task === + + You can use : + {{{ + ./symfony plugin:build-package + }}} + + or + {{{ + ./symfony plugin-build-package + }}} + + The task contain one agrgument : + + * The *plugin_name* : by default it's the name of the skelton xml + +The task contains this options : + + * *--skelton_path* or *-p* : if you want to set an other model (by default: package-*YOUR_PLUGIN_NAME*.xml) + + * *--plugin_version* or *-v* : to set the version of the plugin ( pear format is X.Y.Z ) + + * *--stability* or *-s* : set beta or stable + + * *--changelog* or *-c* : By this options you will set the notes for the changelog of this version + + * *--license_uri* or *-uri* : The uri of you license (default : http://www.symfony-project.com/license ) + + * *--license_name* or *-l* : The name of the license (default : MIT ) + + === Recommanded use === + + + {{{ + + ./symfony plugin:build-package -v="X.Y.Z" -s="beta" -c="Your notes for the version" PLUGIN_NAME + + }}} + + If you have already set the command for a version, but you have forgot something and that you don't want to creant a + new version number : + + * Manke your change and do only : + + {{{ + + ./symfony plugin:build-package PLUGIN_NAME + + }}} + + + + + \ No newline at end of file Added: plugins/sfPackageMaker2Plugin/trunk/lib/task/sfPluginPackageTask.class.php =================================================================== --- plugins/sfPackageMaker2Plugin/trunk/lib/task/sfPluginPackageTask.class.php (rev 0) +++ plugins/sfPackageMaker2Plugin/trunk/lib/task/sfPluginPackageTask.class.php 2010-09-15 15:54:59 UTC (rev 30913) @@ -0,0 +1,194 @@ +<?php +/* + * This file is part of the sfPackageMakerPlugin package. + * (c) 2009 Cedric Lombardot <[email protected]> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * @package symfony.runtime.addon + * @author Cedric Lombardot <[email protected]> + * @version SVN: $Id$ + */ + +class sfPakePackageMakerPlugin extends sfPluginBaseTask{ + + protected function configure(){ + $this->addArguments(array( + new sfCommandArgument('plugin_name', sfCommandArgument::REQUIRED, 'The plugin name'), + )); + $this->addOptions( + array( + new sfCommandOption('skelton_path', 'p', sfCommandOption::PARAMETER_REQUIRED, 'To set an other skelton path for the file', null), + new sfCommandOption('plugin_version', 'v', sfCommandOption::PARAMETER_REQUIRED, 'If you want to set a realease number', null), + new sfCommandOption('stability', 's', sfCommandOption::PARAMETER_REQUIRED, 'The stability of this new realease', null), + new sfCommandOption('changelog', 'c', sfCommandOption::PARAMETER_REQUIRED, 'The changement for this new Realease', null), + new sfCommandOption('license_uri','uri',sfCommandOption::PARAMETER_REQUIRED,'The license uri default MIT','http://www.symfony-project.com/license'), + new sfCommandOption('license_name','l',sfCommandOption::PARAMETER_REQUIRED,'The name of the license default MIT','MIT'), + )); + + + $this->aliases = array('plugin-build-package'); + $this->namespace = 'plugin'; + $this->name = 'build-package'; + + $this->briefDescription = 'create package.xml files from a skeleton'; + + $this->detailedDescription = <<<EOF + This plugin will preparaten your package by analysing all the file to be packaged into + a good pear package + + [ ./symfony plugin:build-package PLUGIN_NAME ] + [ ./symfony plugin-build-package PLUGIN_NAME ] + + * The plugin name is the name of your plugin folder + * At the root of the plugin folder you have to create a copy of the xml file + ./sfPackageMakerPlugin/skelton.xml + The name of this file is by default package-YOUR_PLUGIN_NAME.xml + + I recommand you to set options in this tag to spend less time + + [ ./symfony plugin:build-package -v="PLUGIN_VERSION" -s="STABILITY" -c="CHANGELOG FOR THE RELASE" PLUGIN_NAME ] + + If you use this method, the tack will change the skelton XML by Adding the changelog ... + + After you will ony have to do + + cd plugins + pear package ./[PLUGIN_NAME]/package.xml + + +EOF; + + } + + protected function execute($arguments = array(), $options = array()) + { + /* + * The skeltonPath + */ + $skelton=($options['skelton_path']!="")?$options['skelton_path']:'package-'.$arguments['plugin_name'].'.xml'; + $skelton=sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$skelton; + + if (!file_exists($skelton)){ + throw new sfCommandException(sprintf('Skeleton "%s" not found.', $skelton)); + } + + + $skeletonContents=file_get_contents($skelton); + + $xml = new SimpleXMLElement($skeletonContents); + $xml->date = date('Y-m-d'); + $xml->name = $arguments['plugin_name']; + + + $lfile=sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$xml->name.DIRECTORY_SEPARATOR.'LICENSE'; + if (!file_exists($lfile)){ + $fp=fopen($lfile,'w'); + fputs($fp,$options['license_name'].' '.$options['license_uri']); + fclose($fp); + } + $rfile=sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$xml->name.DIRECTORY_SEPARATOR.'README'; + if (!file_exists($rfile)){ + $fp=fopen($rfile,'w'); + fputs($fp,'== '.$arguments['plugin_name'].' == +### Description + '.$xml->description.' + +### How To Install + + YOUR README HERE + + + '); + fclose($fp); + } + + if(($options['plugin_version'])){ + $xml->version->release=$options['plugin_version']; + $xml->version->api=$options['plugin_version']; + } + + if(!is_null($options['stability'])){ + $xml->stability->release=$options['stability']; + $xml->stability->api=$options['stability']; + } + + if($options['changelog']!=""){ + $release=$xml->changelog->addChild('release'); + + //Version + $version=$release->addChild('version'); + $v_r=$version->addChild('release',$options['plugin_version']); + $api=$version->addChild('api',$options['plugin_version']); + + //stability + $version=$release->addChild('stability'); + $v_r=$version->addChild('release',$options['stability']); + $api=$version->addChild('api',$options['stability']); + + //Licence <license uri="http://www.symfony-project.com/license">MIT license</license> + $license_uri=$release->addChild('license',$options['license_name']); + $license_uri->addAttribute('uri',$options['license_uri']); + + //Date + $date=$release->addChild('date',$xml->date); + + //Notes + $notes=$release->addChild('notes',$options['changelog']); + + + /* + * For the changelog we will replace the skelton + */ + $xml->asXML($skelton); + } + + $xml->license=$options['license_name']; + $xml->license->addAttribute('uri',$options['license_uri']); + + + $xml->contents = ''; + + $rootDir = $xml->contents->addChild('dir'); + $rootDir->addAttribute('name', '/'); + + $this->describe_dir(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$arguments['plugin_name'], $rootDir, true); + + + + + $packagePath = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$xml->name.DIRECTORY_SEPARATOR."package.xml"; + + #pake_echo($rootDir->asXML()); + $xml->asXML($packagePath); + #echo $xml->asXML(); + + } + + private function describe_dir($path, &$dirNode, $firstTime) + { + if (!($d = @opendir($path)) === false) + while ($f = readdir($d)) + { + if ((substr($f,0,1) != '.') && ($f != 'package.xml')) + if (is_dir($dir = $path.DIRECTORY_SEPARATOR.$f)) + { + $child = $dirNode->addChild('dir'); + $child->addAttribute('name',$f); + $this->describe_dir($dir, $child, false); + } + else + { + $child = $dirNode->addChild('file'); + $child->addAttribute('name', $f); + $child->addAttribute('role', 'data'); + } + } + +} + +} +?> \ No newline at end of file Added: plugins/sfPackageMaker2Plugin/trunk/package-skeleton.xml =================================================================== --- plugins/sfPackageMaker2Plugin/trunk/package-skeleton.xml (rev 0) +++ plugins/sfPackageMaker2Plugin/trunk/package-skeleton.xml 2010-09-15 15:54:59 UTC (rev 30913) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package packagerversion="1.4.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> + <name>[automatic]</name> + <channel>pear.symfony-project.com</channel> + <summary></summary> + <description></description> + <lead> + <name>YOUR_NAME</name> + <user>YOUR_USERNAME</user> + <email>YOUR_EMAIL</email> + <active>yes</active> + </lead> + <date>[automatic]</date> + <version> + <release>[automatic]</release> + <api>[automatic]</api> + </version> + <stability> + <release>[automatic]</release> + <api>[automatic]</api> + </stability> +<license>[automatic]</license> + <notes>-</notes> + <contents>[automatic]</contents> + + <dependencies> + <required> + <php> + <min>5.1.0</min> + </php> + <pearinstaller> + <min>1.4.1</min> + </pearinstaller> + <package> + <name>symfony</name> + <channel>pear.symfony-project.com</channel> + <min>1.1.0</min> + <max>1.3.0</max> + <exclude>1.3.0</exclude> + </package> + </required> + </dependencies> + + <phprelease> + </phprelease> + + <changelog> + </changelog> +</package> Added: plugins/sfPackageMaker2Plugin/trunk/package.xml =================================================================== --- plugins/sfPackageMaker2Plugin/trunk/package.xml (rev 0) +++ plugins/sfPackageMaker2Plugin/trunk/package.xml 2010-09-15 15:54:59 UTC (rev 30913) @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> + <name>sfPackageMaker2Plugin</name> + <channel>pear.symfony-project.com</channel> + <summary>create package.xml files from a skeleton</summary> + <description>create package.xml files from a skeleton</description> + <lead> + <name>Cedric Lombardot</name> + <user>lombardot</user> + <email>[email protected]</email> + <active>yes</active> + </lead> + <date>2010-01-29</date> + <time>10:23:51</time> + <version> + <release>1.0.0</release> + <api>1.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.symfony-project.com/license">MIT</license> + <notes> +- + </notes> + <contents> + <dir name="/"> + <file md5sum="4209c7d8638f2229b2f176de6013bdde" name="lib/task/sfPluginPackageTask.class.php" role="data"/> + <file md5sum="d81b882db681e7c17991f196a9b25f99" name="LICENSE" role="data"/> + <file md5sum="e3818f24a7c920e68d9430ae6b511cc6" name="package-skeleton.xml" role="data"/> + <file md5sum="921485592e97d22dd7d71da844d71a75" name="README" role="data"/> + </dir> + </contents> + <dependencies> + <required> + <php> + <min>5.1.0</min> + </php> + <pearinstaller> + <min>1.4.1</min> + </pearinstaller> + + </required> + </dependencies> + <phprelease/> + <changelog> + <release> + <version> + <release>0.2.0</release> + <api>0.2.0</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <license uri="http://www.symfony-project.com/license">MIT</license> + <date>2009-01-26</date> + <notes> +A new version for sf1.2 with more options + </notes> + </release> + <release> + <version> + <release>1.0.0</release> + <api>1.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.symfony-project.com/license">MIT</license> + <date>2010-01-29</date> + <notes> +Set compatible for sf1.3 and 1.4 + </notes> + </release> + </changelog> +</package> -- You received this message because you are subscribed to the Google Groups "symfony SVN" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-svn?hl=en.
