Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drupal Spoons deprecated
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Composer
plugin
Drupal Spoons deprecated
Commits
26582e57
Commit
26582e57
authored
4 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
Split post install and post update tasks
parent
b6855829
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Handler.php
+83
-73
83 additions, 73 deletions
src/Handler.php
src/Plugin.php
+12
-2
12 additions, 2 deletions
src/Plugin.php
with
95 additions
and
75 deletions
src/Handler.php
+
83
−
73
View file @
26582e57
...
...
@@ -41,13 +41,31 @@ class Handler {
$this
->
io
=
$io
;
}
/**
* Configure composer.json.
*/
public
function
configureComposerJson
()
{
$fs
=
new
Filesystem
();
$options
=
$this
->
getOptions
();
$projectRoot
=
getcwd
();
// Append DrupalSpoon related components to composer.json.
$jsonFile
=
new
JsonFile
(
$projectRoot
.
'/composer.json.disabled'
);
$content
=
[];
if
(
$jsonFile
->
exists
())
{
$content
=
$jsonFile
->
read
();
}
$content
=
array_merge_recursive
(
$content
,
$options
);
$jsonFile
->
write
(
$content
);
$fs
->
remove
(
$projectRoot
.
'/composer.json'
);
$fs
->
rename
(
$projectRoot
.
'/composer.json.disabled'
,
$projectRoot
.
'/composer.json'
);
}
/**
* Configure Drupal project for CI and/or local tests.
*/
public
function
configureProject
()
{
$options
=
$this
->
getOptions
();
$fs
=
new
Filesystem
();
$installationManager
=
$this
->
composer
->
getInstallationManager
();
// Directory where the root project is being created.
$projectRoot
=
getcwd
();
...
...
@@ -61,20 +79,11 @@ class Handler {
}
$fs
->
mkdir
(
$moduleRoot
);
foreach
(
scandir
(
$projectRoot
)
as
$item
)
{
if
(
!
in_array
(
$item
,
[
'.
git
'
,
'vemdor'
,
'web'
]))
{
if
(
!
in_array
(
$item
,
[
'.
'
,
'..'
,
'.git'
,
'.idea
'
,
'vemdor'
,
'web'
]))
{
$rel
=
$fs
->
makePathRelative
(
$projectRoot
,
$moduleRoot
);
$fs
->
symlink
(
$rel
,
$moduleRoot
.
"/
$item
"
);
$fs
->
symlink
(
$rel
.
"/
$item
"
,
$moduleRoot
.
"/
$item
"
);
}
}
// Append DrupalSpoon related components to composer.json.
$jsonFile
=
new
JsonFile
(
$projectRoot
.
'/composer.json'
);
$content
=
[];
if
(
$jsonFile
->
exists
())
{
$content
=
$jsonFile
->
read
();
}
$content
=
array_merge_recursive
(
$content
,
$options
);
$jsonFile
->
write
(
$content
);
}
/**
...
...
@@ -86,71 +95,72 @@ class Handler {
protected
function
getOptions
():
array
{
$extra
=
$this
->
composer
->
getPackage
()
->
getExtra
()
+
[
'drupalspoons'
=>
[]];
return
$extra
[
'drupalspoons'
]
+
[
'repositories'
=>
[
[
'type'
=>
'composer'
,
'url'
=>
'https://packages.drupal.org/8'
,
],
],
'require_dev'
=>
[
'composer/installers'
=>
'^1'
,
'drupal/core-composer-scaffold'
=>
'^8.8'
,
'cweagans/composer-patches'
=>
'~1.0'
,
'drupal/core-recommended'
=>
'^8.8'
,
'drupal/core-dev'
=>
'^8.8'
,
'drush/drush'
=>
'^10'
,
'mglaman/phpstan-drupal'
=>
'^0.12'
,
'phpstan/phpstan-deprecation-rules'
=>
'^0.12'
,
'php-parallel-lint/php-parallel-lint'
=>
'^1.2'
,
'zaporylie/composer-drupal-optimizations'
=>
'^1.0'
,
],
'scripts'
=>
[
'si'
=>
'drush si -v --db-url=${SIMPLETEST_DB:-mysql://root:password@mariadb/db}'
,
'phpcs'
=>
'phpcs --runtime-set ignore_warnings_on_exit 1 --runtime-set ignore_errors_on_exit 1 web/modules/custom'
,
'lint'
=>
'parallel-lint --exclude web --exclude vendor .'
,
'webserver'
=>
'cd web && php -S 0.0.0.0:8888 .ht.router.php'
,
'chromedriver'
=>
'chromedriver --port=9515 --verbose --whitelisted-ips --log-path=/tmp/chromedriver.log --no-sandbox'
,
'unit'
=>
'phpunit --verbose web/modules/custom'
,
'phpstan'
=>
'phpstan analyse web/modules/custom'
,
'stylelint'
=>
'yarn --silent --cwd web/core stylelint --formatter verbose --config ./.stylelintrc.json ../modules/custom/**/*.css'
,
'eslint'
=>
'yarn --silent --cwd web/core eslint -c ./.eslintrc.json ../modules/custom'
,
],
'config'
=>
[
'process-timeout'
=>
36000
,
],
'extra'
=>
[
'installer-paths'
=>
[
'web/core'
=>
[
0
=>
'type:drupal-core'
,
],
'web/libraries/{$name}'
=>
[
0
=>
'type:drupal-library'
,
],
'web/modules/contrib/{$name}'
=>
[
0
=>
'type:drupal-module'
,
],
'web/profiles/{$name}'
=>
[
0
=>
'type:drupal-profile'
,
],
'web/themes/{$name}'
=>
[
0
=>
'type:drupal-theme'
,
],
'drush/{$name}'
=>
[
0
=>
'type:drupal-drush'
,
'repositories'
=>
[
[
'type'
=>
'composer'
,
'url'
=>
'https://packages.drupal.org/8'
,
],
],
'drupal-scaffold'
=>
[
'locations'
=>
[
'web-root'
=>
'web/'
,
],
'require_dev'
=>
[
'lakedrops/drupal-spoons'
=>
'dev-master'
,
'composer/installers'
=>
'^1'
,
'drupal/core-composer-scaffold'
=>
'^8.8'
,
'cweagans/composer-patches'
=>
'~1.0'
,
'drupal/core-recommended'
=>
'^8.8'
,
'drupal/core-dev'
=>
'^8.8'
,
'drush/drush'
=>
'^10'
,
'mglaman/phpstan-drupal'
=>
'^0.12'
,
'phpstan/phpstan-deprecation-rules'
=>
'^0.12'
,
'php-parallel-lint/php-parallel-lint'
=>
'^1.2'
,
'zaporylie/composer-drupal-optimizations'
=>
'^1.0'
,
],
'drush'
=>
[
'services'
=>
[
'drush.services.yml'
=>
'^9 || ^10'
,
'scripts'
=>
[
'si'
=>
'drush si -v --db-url=${SIMPLETEST_DB:-mysql://root:password@mariadb/db}'
,
'phpcs'
=>
'phpcs --runtime-set ignore_warnings_on_exit 1 --runtime-set ignore_errors_on_exit 1 web/modules/custom'
,
'lint'
=>
'parallel-lint --exclude web --exclude vendor .'
,
'webserver'
=>
'cd web && php -S 0.0.0.0:8888 .ht.router.php'
,
'chromedriver'
=>
'chromedriver --port=9515 --verbose --whitelisted-ips --log-path=/tmp/chromedriver.log --no-sandbox'
,
'unit'
=>
'phpunit --verbose web/modules/custom'
,
'phpstan'
=>
'phpstan analyse web/modules/custom'
,
'stylelint'
=>
'yarn --silent --cwd web/core stylelint --formatter verbose --config ./.stylelintrc.json ../modules/custom/**/*.css'
,
'eslint'
=>
'yarn --silent --cwd web/core eslint -c ./.eslintrc.json ../modules/custom'
,
],
'config'
=>
[
'process-timeout'
=>
36000
,
],
'extra'
=>
[
'installer-paths'
=>
[
'web/core'
=>
[
0
=>
'type:drupal-core'
,
],
'web/libraries/{$name}'
=>
[
0
=>
'type:drupal-library'
,
],
'web/modules/contrib/{$name}'
=>
[
0
=>
'type:drupal-module'
,
],
'web/profiles/{$name}'
=>
[
0
=>
'type:drupal-profile'
,
],
'web/themes/{$name}'
=>
[
0
=>
'type:drupal-theme'
,
],
'drush/{$name}'
=>
[
0
=>
'type:drupal-drush'
,
],
],
'drupal-scaffold'
=>
[
'locations'
=>
[
'web-root'
=>
'web/'
,
],
],
'drush'
=>
[
'services'
=>
[
'drush.services.yml'
=>
'^9 || ^10'
,
],
],
],
],
];
];
}
}
This diff is collapsed.
Click to expand it.
src/Plugin.php
+
12
−
2
View file @
26582e57
...
...
@@ -43,13 +43,23 @@ class Plugin implements PluginInterface, EventSubscriberInterface, Capable {
*/
public
static
function
getSubscribedEvents
():
array
{
return
[
ScriptEvents
::
POST_INSTALL_CMD
=>
'configure
Project
'
,
ScriptEvents
::
POST_INSTALL_CMD
=>
'configure
ComposerJson
'
,
ScriptEvents
::
POST_UPDATE_CMD
=>
'configureProject'
,
];
}
/**
* Post install and post update command event callback.
* Post install command event callback.
*
* @param \Composer\Script\Event $event
* The event that triggered the plugin.
*/
public
function
configureComposerJson
(
Event
$event
)
{
$this
->
handler
->
configureComposerJson
();
}
/**
* Post update command event callback.
*
* @param \Composer\Script\Event $event
* The event that triggered the plugin.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment