Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
bundle.javascript
Browse files Browse the repository at this point in the history
bundle.stylesheet
  • Loading branch information
elnebuloso committed Feb 5, 2015
1 parent 4e6a3bd commit 09ba8f4
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 8.1.0

- elnebuloso/bundler integration
- bundle.javascript added
- bundle.stylesheet added

## 8.0.3

- bugfix project.package patternset
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.3
8.1.0
1 change: 1 addition & 0 deletions commons/chains/php-website.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<target name="init:main" hidden="true" depends="composer.validate, composer.update" />
<target name="test:main" hidden="true" depends="test.phplint, test.phpunit" />
<target name="bundle:main" hidden="true" depends="bundle.javascript, bundle.stylesheet" />
<target name="package:main" hidden="true" depends="composer.optimize, project.package" />
<target name="build:before" hidden="true" depends="jenkins.environment" />
<target name="build:after" hidden="true" depends="jenkins.environment" />
Expand Down
4 changes: 4 additions & 0 deletions commons/commons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
<!-- ============================================ -->
<!-- commons tasks -->
<!-- ============================================ -->
<taskdef classname="Commons\Phing\Task\Bundle\JavascriptBundlerTask" name="commons-bundle-javascript" />
<taskdef classname="Commons\Phing\Task\Bundle\StylesheetBundlerTask" name="commons-bundle-stylesheet" />
<taskdef classname="Commons\Phing\Task\Jenkins\EnvironmentTask" name="commons-jenkins-environment" />
<taskdef classname="Commons\Phing\Task\System\ImportChainsTask" name="commons-system-import-chains" />
<taskdef classname="Commons\Phing\Task\Composer\FormatTask" name="commons-composer-format" />
Expand All @@ -63,6 +65,7 @@
<!-- ============================================ -->
<!-- phing commons targets -->
<!-- ============================================ -->
<import file="${phing:commons:commons}/targets/bundle.xml" />
<import file="${phing:commons:commons}/targets/clean.xml" />
<import file="${phing:commons:commons}/targets/composer.xml" />
<import file="${phing:commons:commons}/targets/jenkins.xml" />
Expand Down Expand Up @@ -104,6 +107,7 @@
<target name="help.targets" hidden="true">
<echo message="Module Help" />
<echo message="----------------------------------------------------------------------------------------------------" />
<echo message="bundle:help Overview of all Bundle Targets" />
<echo message="clean:help Overview of all Clean Targets" />
<echo message="composer:help Overview of all Composer Targets" />
<echo message="jenkins:help Overview of all Jenkins Targets" />
Expand Down
19 changes: 19 additions & 0 deletions commons/targets/bundle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>


<project default="bundle:help">


<import file="${phing:commons:commons}/targets/bundle/javascript.xml" />
<import file="${phing:commons:commons}/targets/bundle/stylesheet.xml" />


<target name="bundle:help">
<echo message="Bundle Targets" />
<echo message="----------------------------------------------------------------------------------------------------" />
<echo message="bundle.javascript Bundle your Javascript Files" />
<echo message="bundle.stylesheet Bundle your Stylesheet Files" />
</target>


</project>
47 changes: 47 additions & 0 deletions commons/targets/bundle/javascript.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>


<project default="bundle.javascript">


<target name="bundle.javascript:init" hidden="true">
<property name="bundle.javascript.enabled" value="no" />
</target>


<target name="bundle.javascript:before" hidden="true">
<echo message="no actions defined" level="debug" />
</target>


<target name="bundle.javascript:main" hidden="true">
<if>
<istrue value="${bundle.javascript.enabled}" />
<then>
<commons-bundle-javascript file="${project.root}/.bundler/javascript.php" />
</then>
<else>
<echo message="bundling of javascript disabled. enable by property bundle.javascript.enabled set to yes" />
</else>
</if>
</target>


<target name="bundle.javascript:after" hidden="true">
<echo message="no actions defined" level="debug" />
</target>


<target name="bundle.javascript" depends="bundle.javascript:init, bundle.javascript:before, bundle.javascript:main, bundle.javascript:after">
<echo message="successful" />
</target>


<target name="bundle.javascript:help" depends="bundle.javascript:init">
<echo message="Property Value" />
<echo message="----------------------------------------------------------------------------------------------------" />
<echo message="bundle.javascript.enabled yes|no: ${bundle.javascript.enabled}" />
</target>


</project>
47 changes: 47 additions & 0 deletions commons/targets/bundle/stylesheet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>


<project default="bundle.stylesheet">


<target name="bundle.stylesheet:init" hidden="true">
<property name="bundle.stylesheet.enabled" value="no" />
</target>


<target name="bundle.stylesheet:before" hidden="true">
<echo message="no actions defined" level="debug" />
</target>


<target name="bundle.stylesheet:main" hidden="true">
<if>
<istrue value="${bundle.stylesheet.enabled}" />
<then>
<commons-bundle-stylesheet file="${project.root}/.bundler/stylesheet.php" />
</then>
<else>
<echo message="bundling of stylesheet disabled. enable by property bundle.stylesheet.enabled set to yes" />
</else>
</if>
</target>


<target name="bundle.stylesheet:after" hidden="true">
<echo message="no actions defined" level="debug" />
</target>


<target name="bundle.stylesheet" depends="bundle.stylesheet:init, bundle.stylesheet:before, bundle.stylesheet:main, bundle.stylesheet:after">
<echo message="successful" />
</target>


<target name="bundle.stylesheet:help" depends="bundle.stylesheet:init">
<echo message="Property Value" />
<echo message="----------------------------------------------------------------------------------------------------" />
<echo message="bundle.stylesheet.enabled yes|no: ${bundle.stylesheet.enabled}" />
</target>


</project>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"sebastian\/phpcpd": "2.0.1",
"squizlabs\/php_codesniffer": "2.0.0",
"apigen\/apigen": "4.0.0",
"phpunit\/phpunit": "4.4.5"
"phpunit\/phpunit": "4.4.5",
"elnebuloso\/bundler": "~8.1"
},
"config": {
"bin-dir": "bin"
Expand Down
40 changes: 40 additions & 0 deletions src/Commons/Phing/Task/Bundle/JavascriptBundlerTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Commons\Phing\Task\Bundle;

use Bundler\JavascriptBundler;
use Zend\Log\Logger;
use Zend\Log\Writer\Stream as StreamWriter;

/**
* Class JavascriptBundlerTask
*
* @author Jeff Tunessen <jeff.tunessen@gmail.com>
*/
class JavascriptBundlerTask extends \Task {

/**
* @var string
*/
private $file;

/**
* @param string $file
*/
public function setFile($file) {
$this->file = $file;
}

/**
* @throws \BuildException
* @return void
*/
public function main() {
$writer = new StreamWriter('php://output');
$logger = new Logger();
$logger->addWriter($writer);

$bundler = new JavascriptBundler($this->file);
$bundler->getBundlerLogger()->setLogger($logger);
$bundler->bundle();
}
}
40 changes: 40 additions & 0 deletions src/Commons/Phing/Task/Bundle/StylesheetBundlerTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace Commons\Phing\Task\Bundle;

use Bundler\StylesheetBundler;
use Zend\Log\Logger;
use Zend\Log\Writer\Stream as StreamWriter;

/**
* Class StylesheetBundlerTask
*
* @author Jeff Tunessen <jeff.tunessen@gmail.com>
*/
class StylesheetBundlerTask extends \Task {

/**
* @var string
*/
private $file;

/**
* @param string $file
*/
public function setFile($file) {
$this->file = $file;
}

/**
* @throws \BuildException
* @return void
*/
public function main() {
$writer = new StreamWriter('php://output');
$logger = new Logger();
$logger->addWriter($writer);

$bundler = new StylesheetBundler($this->file);
$bundler->getBundlerLogger()->setLogger($logger);
$bundler->bundle();
}
}

0 comments on commit 09ba8f4

Please sign in to comment.