Skip to content
Extraits de code Groupes Projets
Valider 32c57ce8 rédigé par JamesRezo's avatar JamesRezo :tada:
Parcourir les fichiers

feat(security): automatic update for safety screen

parent 210724e9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
## [Unreleased]
### Added
- `composer spip:local` command
- `composer spip:set-ssh-url` comand
### Deprecated
- Safety Screen composer script
- ModeDev composer script
## [0.5.1] - 2023-03-24
### Added
- ModeDev composer script
## [0.5.0] - 2023-03-19
### Changed
- Composer version
### Fixed
- Unit tests
## [0.4.3] - 2021-10-06
### Changed
- Composer version
## [0.4.2] - 2021-05-02
### Changed
- Composer version
## [0.4.1] - 2020-08-21
### Fixed
- Exclude files/directories from Classic copy on install
## [0.4.0] - 2020-08-20
### Changed
- Composer 2.0 API
## [0.3.0] - 2019-05-01
### Added
- Safety Screen composer script
## [0.2] - 2018-05-02
### Added
- Unit tests
- spip-ecrire, spip-prive types
- spip-plugin, extra.spip.template, extra.spip.extensions
### Removed
- spip-cms type
......@@ -35,22 +35,22 @@ Composer Plugin to Install SPIP Applications.
## Mode Dev
```json
{
"config": {
"preferred-install": {
"spip/*": "source"
}
},
"scripts": {
"mode-dev": [
"Spip\\Composer\\ModeDev::activate"
]
}
}
```
### spip:local
- `composer spip:local <command> <args>`
- `composer local <command> <args>`
- `composer l <command> <args>`
### spip:set-ssh-url
- `composer spip:set-ssh-url`
- `composer mode-dev`
```bash
composer install
composer mode-dev
# Interfactive
composer local mode-dev
# Non-interfactive
composer local mode-dev -n
composer local require --dev symfony/var-dumper flip/whoops
composer local install
```
......@@ -4,6 +4,7 @@ namespace Spip\Composer;
use Composer\Script\Event;
use Composer\Util\Filesystem;
use Composer\Package\Link;
/**
* Script for post-install-cmd and post-update-cmd.
......@@ -11,25 +12,57 @@ use Composer\Util\Filesystem;
class Security
{
/**
* To move the security screen after download in the config directory of the project.
* @deprecated 0.6.0
*/
public static function postInstall(Event $event)
{
static::copySafetyScreen($event);
}
/**
* @deprecated 0.6.0
*/
public static function postUpdate(Event $event)
{
static::copySafetyScreen($event);
}
/**
* To move the safety screen after download in the config directory of the project.
*
* @param $event
* @param $event
*
* @return void
*/
public static function postInstall(Event $event)
public static function copySafetyScreen(Event $event)
{
$search = array_filter(
$event->getComposer()->getPackage()->getRequires(),
function (Link $link) {
return $link->getTarget() === 'spip/security';
}
);
if (empty($search)) {
$event->getIO()->warning('spip/security is not installed.');
return;
}
$filesystem = new Filesystem();
$event->getIO()->write('Updating the safety screen ...');
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
if (!\is_writable($vendorDir . '/../config/ecran_securite.php')) {
$event->getIO()->error('can\'t write config/ecran_securite.php.');
return;
}
$filesystem->copy(
$vendorDir . '/spip/security/ecran_securite.php',
$vendorDir . '/../config/ecran_securite.php'
);
}
public static function postUpdate(Event $event)
{
static::postInstall($event);
try {
$filesystem->copy(
$vendorDir . '/spip/security/ecran_securite.php',
$vendorDir . '/../config/ecran_securite.php'
);
$event->getIO()->write('Done.');
} catch (\Throwable $th) {
$event->getIO()->error($th->getMessage());
}
}
}
......@@ -3,14 +3,13 @@
namespace Spip\Composer;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\Capable;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
/**
* @codeCoverageIgnore
*/
class SpipInstallerPlugin implements PluginInterface, Capable
class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface, Capable
{
public function activate(Composer $composer, IOInterface $io)
{
......@@ -26,6 +25,19 @@ class SpipInstallerPlugin implements PluginInterface, Capable
{
}
public static function getSubscribedEvents()
{
return [
'post-install-cmd' => 'updateSafetyScreen',
'post-update-cmd' => 'updateSafetyScreen',
];
}
public function updateSafetyScreen(Event $event)
{
Security::copySafetyScreen($event);
}
public function getCapabilities()
{
return [
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter