From 4087b7340b01826b41ee79a96e6badcdc614e4aa Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Fri, 27 May 2016 11:34:22 -0700 Subject: [PATCH 1/8] Special handling for composer-based workflows --- bootstrap.js | 33 +++++++++++++++++++++------------ tasks/composer.js | 9 +++++++++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index bf2578ba..65bb5079 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -39,25 +39,34 @@ 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'])) { + // Run `composer install` if there is already a lock file. Updates should be explicit once this file exists. tasksDefault.unshift('composer:install'); } + 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'); } diff --git a/tasks/composer.js b/tasks/composer.js index d9b7e8ae..d6480486 100644 --- a/tasks/composer.js +++ b/tasks/composer.js @@ -20,6 +20,15 @@ module.exports = function(grunt) { ], } }); + grunt.config(['composer', 'update'], { + options: { + flags: [ + 'no-interaction', + 'no-progress', + 'prefer-dist' + ], + } + }); Help.add({ task: 'composer', From cd480896b70637df8289633ade57c037cb5fdb06 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 9 Jun 2016 10:44:11 -0700 Subject: [PATCH 2/8] Tests for composer-based workflows --- example/composer.json | 60 +++++++++++++++---- .../composer.json | 5 +- .../test_assets}/src/project.make | 0 test/test_assets_d8/src/project.make | 15 ----- 4 files changed, 50 insertions(+), 30 deletions(-) rename test/{test_assets_d8 => test_assets}/composer.json (67%) rename {example => test/test_assets}/src/project.make (100%) delete mode 100644 test/test_assets_d8/src/project.make diff --git a/example/composer.json b/example/composer.json index 2295c0a8..bc512b54 100644 --- a/example/composer.json +++ b/example/composer.json @@ -1,14 +1,52 @@ { - "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" } + ], + "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", + "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" + ] + } + } } diff --git a/test/test_assets_d8/composer.json b/test/test_assets/composer.json similarity index 67% rename from test/test_assets_d8/composer.json rename to test/test_assets/composer.json index ea21fa19..2295c0a8 100644 --- a/test/test_assets_d8/composer.json +++ b/test/test_assets/composer.json @@ -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" diff --git a/example/src/project.make b/test/test_assets/src/project.make similarity index 100% rename from example/src/project.make rename to test/test_assets/src/project.make diff --git a/test/test_assets_d8/src/project.make b/test/test_assets_d8/src/project.make deleted file mode 100644 index 48ee88b3..00000000 --- a/test/test_assets_d8/src/project.make +++ /dev/null @@ -1,15 +0,0 @@ -core = 8.x -api = 2 - -; Drupal Core -projects[drupal][version] = "8.0.4" - -; ===================================== -; Contrib Modules -; ===================================== - -; By default, store all contrib modules in the "contrib" subdirectory of -; sites/all/modules. -defaults[projects][subdir] = "contrib" - -projects[devel][version] = 1.x From e5151180a35455f04b50c35982279ebed45f8d7e Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 9 Jun 2016 11:43:55 -0700 Subject: [PATCH 3/8] Run `composer drupal-scaffold` after `composer install` --- bootstrap.js | 2 ++ tasks/composer.js | 1 + 2 files changed, 3 insertions(+) diff --git a/bootstrap.js b/bootstrap.js index 65bb5079..0766be8b 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -59,6 +59,8 @@ module.exports = function(grunt) { tasksDefault.push('scaffold'); 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'); } diff --git a/tasks/composer.js b/tasks/composer.js index d6480486..6ce72379 100644 --- a/tasks/composer.js +++ b/tasks/composer.js @@ -29,6 +29,7 @@ module.exports = function(grunt) { ], } }); + grunt.config(['composer', 'drupal-scaffold'], {}); Help.add({ task: 'composer', From d367892c8d0b9d2032dd2ccd673630053f991ab1 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 9 Jun 2016 12:35:13 -0700 Subject: [PATCH 4/8] Fix coding standards for test assets --- .../src/modules/gdt_test/tests/src/Unit/PassTest.php | 5 ----- test/test_assets_d8/src/modules/test.php | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/test_assets_d8/src/modules/gdt_test/tests/src/Unit/PassTest.php b/test/test_assets_d8/src/modules/gdt_test/tests/src/Unit/PassTest.php index 2e13a6e8..756f0e33 100644 --- a/test/test_assets_d8/src/modules/gdt_test/tests/src/Unit/PassTest.php +++ b/test/test_assets_d8/src/modules/gdt_test/tests/src/Unit/PassTest.php @@ -1,9 +1,4 @@ Date: Thu, 9 Jun 2016 12:45:01 -0700 Subject: [PATCH 5/8] Test without .make files for Drupal 8. --- test/test_assets_d8/Gruntconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_assets_d8/Gruntconfig.json b/test/test_assets_d8/Gruntconfig.json index 7839543b..d46341a7 100644 --- a/test/test_assets_d8/Gruntconfig.json +++ b/test/test_assets_d8/Gruntconfig.json @@ -1,7 +1,6 @@ { "domain": "http://127.0.0.1:8080", "srcPaths": { - "make": "src/project.make", "drupal": "src" }, "siteUrls": { From eee347d7a52bd6022de20f03e852cf9b556c0f51 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 9 Jun 2016 13:30:26 -0700 Subject: [PATCH 6/8] Require phpunit --- example/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/example/composer.json b/example/composer.json index bc512b54..b9fe5148 100644 --- a/example/composer.json +++ b/example/composer.json @@ -20,6 +20,7 @@ "drush/drush": "~8.0", "drupal/console": "~0.10", "phpmd/phpmd": "~2.1", + "phpunit/phpunit": "~4.8", "drupal/coder": "^8.2" }, "conflict": { From 446de97d54b1c782405a37d1e55d1322218e7eb2 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Wed, 15 Jun 2016 13:58:09 -0700 Subject: [PATCH 7/8] Update composer repository to use drupal.org --- example/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/composer.json b/example/composer.json index b9fe5148..0c49dc28 100644 --- a/example/composer.json +++ b/example/composer.json @@ -4,7 +4,7 @@ "repositories": [ { "type": "composer", - "url": "https://packagist.drupal-composer.org" + "url": "https://packages.drupal.org/8" } ], "require": { From f718c0e6ca9723c7fdcd60e1cfbb718d53fbce16 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Wed, 15 Jun 2016 14:00:30 -0700 Subject: [PATCH 8/8] Document composer workflow for Drupal 8 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b55c3fd7..c8816b29 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ This project is built on the tools of the Grunt community to provide scripted automation of a number of PHP & Drupal tasks. Here are a few examples of what it provides: -* Drush make-based build workflow +* Composer workflow + * Drush make-based build workflow (for Drupal 7.x) * CI portability (used with Jenkins so far) * Opt-in for a number of great enhancements: * Composer dependency management for PHP