Browse Source

spip/classic installation

pull/1/head
JamesRezo 4 years ago
parent
commit
ab6a6b342a
  1. 7
      .gitignore
  2. 2
      LICENSE
  3. 29
      composer.json
  4. 22
      composer.lock
  5. 30
      src/Classic.php
  6. 50
      src/SpipInstaller.php
  7. 16
      src/SpipInstallerPlugin.php

7
.gitignore

@ -1,8 +1,3 @@
# ---> Composer
composer.phar
/vendor/
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
.php_cs.cache

2
LICENSE

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2018 James Hautot
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

29
composer.json

@ -0,0 +1,29 @@
{
"name": "spip/composer-installer",
"description": "SPIP Composer Installer Plugin",
"type": "composer-plugin",
"license": "MIT",
"authors": [
{
"name": "James Hautot",
"email": "james@rezo.net"
}
],
"require": {
"php": "^5.3|^7",
"composer-plugin-api": "^1.0"
},
"config": {
"platform": {
"php": "5.3.29"
}
},
"extra": {
"class": "Spip\\Composer\\SpipInstallerPlugin"
},
"autoload": {
"psr-4": {
"Spip\\Composer\\": "src/"
}
}
}

22
composer.lock

@ -0,0 +1,22 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "14ab785b945f25003a1ae28694468198",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "^5.3|^7"
},
"platform-dev": [],
"platform-overrides": {
"php": "5.3.29"
}
}

30
src/Classic.php

@ -0,0 +1,30 @@
<?php
namespace Spip\Composer;
use Composer\Script\Event;
use Composer\Util\Filesystem;
/**
* Script for post-install-cmd and post-install-cmd.
*/
class Classic
{
/**
* To move spip/classic after download to the root of the project.
*
* @param $event
*
* @return void
*/
public static function postInstall(Event $event)
{
$filesystem = new Filesystem();
$rootDir = realpath($event->getComposer()->getConfig()->get('vendor-dir') . '/..');
$filesystem->remove($rootDir . 'tmp/__spip_classic__/composer.json');
$filesystem->remove($rootDir . 'tmp/__spip_classic__/composer.lock');
$filesystem->copy($rootDir . 'tmp/__spip_classic__', $rootDir);
$filesystem->remove($rootDir . 'tmp/__spip_classic__');
}
}

50
src/SpipInstaller.php

@ -0,0 +1,50 @@
<?php
namespace Spip\Composer;
use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;
class SpipInstaller extends LibraryInstaller
{
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package)
{
if ('spip-classic' === $package->getType()) {
return './tmp/__spip_classic__';
}
if (in_array($package->getType(), array(
'spip-ecrire',
'spip-prive',
'spip-cms',
'spip-lang',
'spip-theme',
'spip-plugin'
))) {
throw new \InvalidArgumentException(
'Unable to install this package as its type is not supported for now.'.
' Wait for SPIP3.3 for using it.'
);
}
}
/**
* {@inheritDoc}
*/
public function supports($packageType)
{
return in_array($packageType, array(
'spip-classic', //SPIP Classic a.k.a. v3.0 to v3.2
//Until SPIP 4.0 some packages need to be installed in some particular places
'spip-cms', //SPIP CMS Component v3.4+ a.k.a. spip/cms
'spip-ecrire', //SPIP CMS Component a.k.a. spip/ecrire v3.3
'spip-prive', //SPIP CMS Component a.k.a. spip/prive v3.3
'spip-lang', //SPIP CMS Component a.k.a. spip/lang v3.3
'spip-theme', //SPIP CMS Component a.k.a. spip/theme v3.3
'spip-plugin', //an optional or required SPIP plugin or the default template
));
}
}

16
src/SpipInstallerPlugin.php

@ -0,0 +1,16 @@
<?php
namespace Spip\Composer;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
class SpipInstallerPlugin implements PluginInterface
{
public function activate(Composer $composer, IOInterface $io)
{
$installer = new SpipInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
}
}
Loading…
Cancel
Save