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

Special handling for composer-based workflows #284

Merged
merged 8 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from 6 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
35 changes: 23 additions & 12 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,36 @@ module.exports = function(grunt) {
tasksDefault.push('validate');
}

// If build/html exists, but is empty, skip the newer check.
// This facilitates situations where the build/html is generated as a mounted
// directory point with a newer timestamp than the Drush Makefiles.
//
// We do not use the grunt-newer .cache with drushmake so skipping newer for
// any one run does not impact later behavior.
if (grunt.file.exists(grunt.config.get('config.buildPaths.html') + '/index.php')) {
tasksDefault.push('newer:drushmake:default');
}
else {
tasksDefault.push('drushmake:default');
// Process .make files if configured.
if (grunt.config.get('config.srcPaths.make')) {
// If build/html exists, but is empty, skip the newer check.
// This facilitates situations where the build/html is generated as a mounted
// directory point with a newer timestamp than the Drush Makefiles.
//
// We do not use the grunt-newer .cache with drushmake so skipping newer for
// any one run does not impact later behavior.
if (grunt.file.exists(grunt.config.get('config.buildPaths.html') + '/index.php')) {
tasksDefault.push('newer:drushmake:default');
}
else {
tasksDefault.push('drushmake:default');
}
}

// Wire up the generated docroot to our custom code.
tasksDefault.push('scaffold');

if (grunt.config.get(['composer', 'install'])) {
if (grunt.file.exists('./composer.lock') && grunt.config.get(['composer', 'install'])) {
// Manually run `composer drupal-scaffold` since this is only automatically run on update.
tasksDefault.unshift('composer:drupal-scaffold');
// Run `composer install` if there is already a lock file. Updates should be explicit once this file exists.
tasksDefault.unshift('composer:install');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to manually run composer drupal-scaffold here too, or go figure out why Drupal Scaffold removed it.

}
else if (grunt.config.get(['composer', 'update'])) {
// Run `composer update` if no lock file exists. This forces `composer drupal-scaffold` to run.
tasksDefault.unshift('composer:update');
}

if (grunt.task.exists('bundle-install')) {
tasksDefault.unshift('bundle-install');
}
Expand Down
61 changes: 50 additions & 11 deletions example/composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
{
"name": "client/project",
"description": "{Project} drupal codebase for {client}.",
"require-dev": {
"behat/mink-zombie-driver": "~1.2",
"drupal/drupal-extension": "~3.0",
"drush/drush": "^8",
"drupal/coder": "^8.2",
"phpmd/phpmd": "~2.1"
},
"require": {
"roave/security-advisories": "dev-master"
"name": "client/project",
"description": "{Project} drupal codebase for {client}.",
"repositories": [
{
"type": "composer",
"url": "https://packagist.drupal-composer.org"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use this PR to adjust to https://packages.drupal.org/8?

}
],
"require": {
"composer/installers": "^1.0.20",
"drupal-composer/drupal-scaffold": "^2.0.1",
"cweagans/composer-patches": "~1.0",
"drupal/core": "~8.1",
"roave/security-advisories": "dev-master"
},
"require-dev": {
"behat/mink-zombie-driver": "~1.2",
"drupal/drupal-extension": "~3.0",
"drush/drush": "~8.0",
"drupal/console": "~0.10",
"phpmd/phpmd": "~2.1",
"phpunit/phpunit": "~4.8",
"drupal/coder": "^8.2"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold"
},
"extra": {
"installer-paths": {
"build/html/core": [
"type:drupal-core"
],
"build/html/modules/contrib/{$name}": [
"type:drupal-module"
],
"build/html/profiles/contrib/{$name}": [
"type:drupal-profile"
],
"build/html/themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/contrib/{$name}": [
"type:drupal-drush"
]
}
}
}
10 changes: 10 additions & 0 deletions tasks/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ module.exports = function(grunt) {
],
}
});
grunt.config(['composer', 'update'], {
options: {
flags: [
'no-interaction',
'no-progress',
'prefer-dist'
],
}
});
grunt.config(['composer', 'drupal-scaffold'], {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our use of composer is now getting complicated enough that we need some more documentation on what's going on. In the pre-v1.0 branch we have a significant refactor to documentation, so it should be based on the work there.

I assume grunt composer:drupal-scaffold is something we might right after composer vendor/dependencies are installed, but before the grunt scaffold symlinks are in place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. Since grunt scaffoldrequires the index.php and the drush status check, the grunt composer:drupal-scaffold needs to run before it.


Help.add({
task: 'composer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
"behat/mink-zombie-driver": "~1.2",
"drupal/drupal-extension": "~3.0",
"drush/drush": "^8",
"phpmd/phpmd": "~2.1",
"drupal/coder": "^8.2",
"guzzlehttp/guzzle" : "^6.0@dev",
"symfony/dependency-injection": "2.7.*",
"symfony/event-dispatcher": "2.7.*"
"phpmd/phpmd": "~2.1"
},
"require": {
"roave/security-advisories": "dev-master"
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion test/test_assets_d8/Gruntconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"domain": "http://127.0.0.1:8080",
"srcPaths": {
"make": "src/project.make",
"drupal": "src"
},
"siteUrls": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\Tests\gdt_test\Unit\PassTest
*/

namespace Drupal\Tests\gdt_test\Unit;

use Drupal\Tests\UnitTestCase;
Expand Down
5 changes: 4 additions & 1 deletion test/test_assets_d8/src/modules/test.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
/**
* @file
* A doc comment for coding standards.
*/

$x = 10;

15 changes: 0 additions & 15 deletions test/test_assets_d8/src/project.make

This file was deleted.