Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLT-1436: porting frontend tasks to robo. #1437

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/blt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $robo_namespaces = [
'ci',
'custom',
'drupal',
'frontend',
'setup',
'tests',
'vm',
Expand Down
3 changes: 0 additions & 3 deletions phing/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
<!-- E.g., commit build artifacts, push to remote. -->
<import file="${phing.dir}/tasks/deploy.xml"/>

<!-- Contains frontend tasks. -->
<import file="${phing.dir}/tasks/frontend.xml"/>

<!-- Contains local syncing tasks. -->
<import file="${phing.dir}/tasks/local-sync.xml"/>

Expand Down
2 changes: 1 addition & 1 deletion phing/tasks/deploy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@

<target name="deploy:build" description="Generates a deploy-ready build in deploy.dir.">

<phingcall target="frontend"/>
<exec dir="${repo.root}" command="${composer.bin}/blt frontend" logoutput="true" checkreturn="true" passthru="true" />
<exec dir="${repo.root}" command="${composer.bin}/blt setup:hash-salt" logoutput="true" checkreturn="true"/>
<phingcall target="deploy:copy"/>
<phingcall target="deploy:composer:install"/>
Expand Down
19 changes: 0 additions & 19 deletions phing/tasks/frontend.xml

This file was deleted.

9 changes: 9 additions & 0 deletions readme/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,12 @@ Project level, functional PHPUnit tests are included in `tests/phpunit`. Any PHP
* [Test Driven Development: By Example (book)](http://www.amazon.com/dp/0321146530)
* [xUnit Test Patterns: Refactoring Test Code (book for the really serious)](http://amazon.com/dp/0131495054)
* [Unit testing: Why bother?](http://soundsoftware.ac.uk/unit-testing-why-bother/)


## Frontend Testing

BLT supports a `frontend-test` target that can be used to execute a variety of testing frameworks. Examples may include Jest, Jasmine, Mocha, Chai, etc.

### Configuration

You can [customize the configuration values](extending-blt.md#modifying-blt-configuration) for the `frontend-test` key to enable this capability of BLT.
56 changes: 56 additions & 0 deletions src/Robo/Commands/Frontend/FrontendCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Acquia\Blt\Robo\Commands\Frontend;

use Acquia\Blt\Robo\BltTasks;

/**
* Defines commands in the "frontend:*" namespace.
*/
class FrontendCommand extends BltTasks {

/**
* Runs all frontend targets
*
* @command frontend
*/
public function frontend() {
$this->say("Running frontend tasks...");
$status_code = $this->invokeCommands([
'frontend:build',
'frontend:setup',
'frontend:test',
]);
return $status_code;
}

/**
* Uses project.yml hooks to run custom defined commands to
* build front end dependencies for custom themes.
*
* @command frontend:build
*/
public function build() {
$this->invokeHook('frontend-build');
}

/**
* Uses project.yml hooks to run custom defined commands to
* setup front end dependencies for frontend:build.
*
* @command frontend:setup
*/
public function setup() {
$this->invokeHook('frontend-setup');
}

/**
* Uses project.yml hooks to run tests for the frontend as
*
* @command frontend:test
*/
public function test() {
$this->invokeHook('frontend-test');
}

}
5 changes: 5 additions & 0 deletions template/blt/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ target-hooks:
dir: ${docroot}
# E.g., `npm run build`.
command: echo 'No frontend-build configured.'
frontend-test:
# E.g., ${docroot}/sites/all/themes/custom/mytheme.
dir: ${docroot}
# E.g., `npm test`.
command: echo 'No frontend-tests configured.'
# Executed before configuration is imported.
pre-config-import:
dir: ${docroot}
Expand Down