-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b75c04
commit 0ae1762
Showing
7 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Editor configuration normalization | ||
# @see http://editorconfig.org/ | ||
|
||
# This is the top-most .editorconfig file; do not search in parent directories. | ||
root = true | ||
|
||
# All files. | ||
[*] | ||
end_of_line = LF | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore files for distribution archives. | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
phpstan.neon export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
/vendor/ | ||
/.idea/ | ||
/composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# A Composer plugin for Toolkit | ||
|
||
This plugin will print any existing notification from the QA Website API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "ec-europa/toolkit-composer-plugin", | ||
"description": "A Composer plugin for Toolkit", | ||
"type": "composer-plugin", | ||
"license": "MIT", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"Toolkit\\ComposerPlugin\\": "src" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=8.1", | ||
"composer-plugin-api": "^2.0" | ||
}, | ||
"require-dev": { | ||
"composer/composer": "^2.0", | ||
"phpstan/extension-installer": "^1.3" | ||
}, | ||
"extra": { | ||
"class": "Toolkit\\ComposerPlugin\\Plugin" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"phpstan/extension-installer": true | ||
} | ||
}, | ||
"scripts": { | ||
"notifications": "Toolkit\\ComposerPlugin\\Plugin::runNotifications", | ||
"test": "./vendor/bin/phpstan --configuration=phpstan.neon" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
parameters: | ||
level: 9 | ||
paths: | ||
- src | ||
excludePaths: | ||
- vendor | ||
ignoreErrors: | ||
- | ||
message: "#^Unsafe usage of new static\\(\\)\\.$#" | ||
count: 1 | ||
path: src/Plugin.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Toolkit\ComposerPlugin; | ||
|
||
use Composer\Composer; | ||
use Composer\EventDispatcher\EventSubscriberInterface; | ||
use Composer\IO\IOInterface; | ||
use Composer\Plugin\PluginInterface; | ||
use Composer\Script\Event; | ||
use Composer\Script\ScriptEvents; | ||
use Composer\Util\ProcessExecutor; | ||
|
||
/** | ||
* Toolkit composer plugin. | ||
*/ | ||
class Plugin implements PluginInterface, EventSubscriberInterface | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function activate(Composer $composer, IOInterface $io) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function deactivate(Composer $composer, IOInterface $io) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function uninstall(Composer $composer, IOInterface $io) | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
ScriptEvents::POST_INSTALL_CMD => 'notifications', | ||
ScriptEvents::POST_UPDATE_CMD => 'notifications', | ||
]; | ||
} | ||
|
||
/** | ||
* Print the Toolkit notifications. | ||
*/ | ||
public function notifications(Event $event): void | ||
{ | ||
$binDir = $event->getComposer()->getConfig()->get('bin-dir') ?: 'vendor/bin'; | ||
$runner = "$binDir/run"; | ||
if (!file_exists($runner)) { | ||
return; | ||
} | ||
$output = ''; | ||
(new ProcessExecutor($event->getIO())) | ||
->execute("$runner toolkit:notifications", $output); | ||
if (!empty($output)) { | ||
$event->getIO()->write($output); | ||
} | ||
} | ||
|
||
/** | ||
* Manually execute the notifications command. | ||
*/ | ||
public static function runNotifications(Event $event): void | ||
{ | ||
(new static())->notifications($event); | ||
} | ||
|
||
} |