@@ -89,22 +89,30 @@ public function onPostCmdEvent(\Composer\Script\Event $event) {
89
89
// Only install the scaffolding if drupal/core was installed,
90
90
// AND there are no scaffolding files present.
91
91
if (isset ($ this ->drupalCorePackage )) {
92
- $ this ->downloadScaffold ();
92
+ $ this ->downloadScaffold ($ event -> isDevMode () );
93
93
// Generate the autoload.php file after generating the scaffold files.
94
94
$ this ->generateAutoload ();
95
95
}
96
96
}
97
97
98
98
/**
99
99
* Downloads drupal scaffold files for the current process.
100
+ *
101
+ * @param bool $dev
102
+ * TRUE if dev packages are installed. FALSE otherwise.
100
103
*/
101
- public function downloadScaffold () {
104
+ public function downloadScaffold ($ dev = FALSE ) {
102
105
$ drupalCorePackage = $ this ->getDrupalCorePackage ();
103
106
$ webroot = realpath ($ this ->getWebRoot ());
104
107
105
- // Collect options, excludes and settings files.
108
+ // Collect options, excludes, dev and settings files.
106
109
$ options = $ this ->getOptions ();
107
- $ files = array_diff ($ this ->getIncludes (), $ this ->getExcludes ());
110
+ $ includes = $ this ->getIncludes ();
111
+ // Check dev files if necessary.
112
+ if ($ dev ) {
113
+ $ includes = array_merge ($ includes , $ this ->getDev ());
114
+ }
115
+ $ files = array_diff ($ includes , $ this ->getExcludes ());
108
116
109
117
// Call any pre-scaffold scripts that may be defined.
110
118
$ dispatcher = new EventDispatcher ($ this ->composer , $ this ->io );
@@ -259,6 +267,15 @@ protected function getIncludes() {
259
267
return $ this ->getNamedOptionList ('includes ' , 'getIncludesDefault ' );
260
268
}
261
269
270
+ /**
271
+ * Retrieve list of additional dev files from optional "extra" configuration.
272
+ *
273
+ * @return array
274
+ */
275
+ protected function getDev () {
276
+ return $ this ->getNamedOptionList ('dev ' , 'getDevDefault ' );
277
+ }
278
+
262
279
/**
263
280
* Retrieve list of initial files from optional "extra" configuration.
264
281
*
@@ -298,6 +315,7 @@ protected function getOptions() {
298
315
'excludes ' => [],
299
316
'includes ' => [],
300
317
'initial ' => [],
318
+ 'dev ' => [],
301
319
'source ' => 'http://cgit.drupalcode.org/drupal/plain/{path}?h={version} ' ,
302
320
// Github: https://raw.githubusercontent.com/drupal/drupal/{version}/{path}
303
321
];
@@ -315,32 +333,48 @@ protected function getExcludesDefault() {
315
333
* Holds default settings files list.
316
334
*/
317
335
protected function getIncludesDefault () {
318
- $ version = $ this ->getDrupalCoreVersion ($ this ->getDrupalCorePackage ());
319
- list ($ major , $ minor ) = explode ('. ' , $ version , 3 );
320
- $ version = "$ major. $ minor " ;
321
-
322
336
/**
323
337
* Files from 8.3.x
324
338
*
325
339
* @see http://cgit.drupalcode.org/drupal/tree/?h=8.3.x
326
340
*/
327
341
$ common = [
328
- '.csslintrc ' ,
329
- '.editorconfig ' ,
330
- '.eslintignore ' ,
331
- '.gitattributes ' ,
332
342
'.htaccess ' ,
333
343
'index.php ' ,
334
344
'robots.txt ' ,
335
345
'sites/default/default.settings.php ' ,
336
346
'sites/default/default.services.yml ' ,
337
- 'sites/development.services.yml ' ,
338
347
'sites/example.settings.local.php ' ,
339
348
'sites/example.sites.php ' ,
340
349
'update.php ' ,
341
350
'web.config '
342
351
];
343
352
353
+ return $ common ;
354
+ }
355
+
356
+ /**
357
+ * Holds default dev files list.
358
+ */
359
+ protected function getDevDefault () {
360
+ $ version = $ this ->getDrupalCoreVersion ($ this ->getDrupalCorePackage ());
361
+ list ($ major , $ minor ) = explode ('. ' , $ version , 3 );
362
+ $ version = "$ major. $ minor " ;
363
+
364
+ /**
365
+ * Files from 8.3.x
366
+ *
367
+ * @see http://cgit.drupalcode.org/drupal/tree/?h=8.3.x
368
+ */
369
+ $ common = [
370
+ '.csslintrc ' ,
371
+ '.editorconfig ' ,
372
+ '.eslintignore ' ,
373
+ '.eslintrc.json ' ,
374
+ '.gitattributes ' ,
375
+ 'sites/development.services.yml ' ,
376
+ ];
377
+
344
378
// Version specific variations.
345
379
if (Semver::satisfies ($ version , '<8.3 ' )) {
346
380
$ common [] = '.eslintrc ' ;
0 commit comments