This commit is contained in:
wangjinlei
2022-11-23 14:48:15 +08:00
parent 0a92e69b83
commit ec59e99a8b
636 changed files with 59164 additions and 46329 deletions

View File

@@ -3,7 +3,6 @@
namespace think\composer;
use Composer\Composer;
use Composer\Installer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
@@ -21,6 +20,15 @@ class Plugin implements PluginInterface
//扩展
$manager->addInstaller(new ThinkExtend($io, $composer));
}
public function deactivate(Composer $composer, IOInterface $io)
{
}
}
public function uninstall(Composer $composer, IOInterface $io)
{
}
}

View File

@@ -11,7 +11,6 @@
namespace think\composer;
use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
@@ -20,15 +19,16 @@ class ThinkExtend extends LibraryInstaller
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
parent::install($repo, $package);
$this->copyExtraFiles($package);
return parent::install($repo, $package)->then(function () use ($package) {
$this->copyExtraFiles($package);
});
}
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
parent::update($repo, $initial, $target);
$this->copyExtraFiles($target);
return parent::update($repo, $initial, $target)->then(function () use ($target) {
$this->copyExtraFiles($target);
});
}
protected function copyExtraFiles(PackageInterface $package)
@@ -74,4 +74,4 @@ class ThinkExtend extends LibraryInstaller
{
return 'think-extend' === $packageType;
}
}
}

View File

@@ -2,19 +2,21 @@
namespace think\composer;
use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use InvalidArgumentException;
class ThinkFramework extends LibraryInstaller
{
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
parent::install($repo, $package);
if ($this->composer->getPackage()->getType() == 'project' && $package->getInstallationSource() != 'source') {
//remove tests dir
$this->filesystem->removeDirectory($this->getInstallPath($package) . DIRECTORY_SEPARATOR . 'tests');
}
return parent::install($repo, $package)->then(function () use ($package) {
if ($this->composer->getPackage()
->getType() == 'project' && $package->getInstallationSource() != 'source') {
//remove tests dir
$this->filesystem->removeDirectory($this->getInstallPath($package) . DIRECTORY_SEPARATOR . 'tests');
}
});
}
/**
@@ -23,7 +25,7 @@ class ThinkFramework extends LibraryInstaller
public function getInstallPath(PackageInterface $package)
{
if ('topthink/framework' !== $package->getPrettyName()) {
throw new \InvalidArgumentException('Unable to install this library!');
throw new InvalidArgumentException('Unable to install this library!');
}
if ($this->composer->getPackage()->getType() !== 'project') {
@@ -42,11 +44,12 @@ class ThinkFramework extends LibraryInstaller
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
parent::update($repo, $initial, $target);
if ($this->composer->getPackage()->getType() == 'project' && $target->getInstallationSource() != 'source') {
//remove tests dir
$this->filesystem->removeDirectory($this->getInstallPath($target) . DIRECTORY_SEPARATOR . 'tests');
}
return parent::update($repo, $initial, $target)->then(function () use ($target) {
if ($this->composer->getPackage()->getType() == 'project' && $target->getInstallationSource() != 'source') {
//remove tests dir
$this->filesystem->removeDirectory($this->getInstallPath($target) . DIRECTORY_SEPARATOR . 'tests');
}
});
}
/**
@@ -56,4 +59,4 @@ class ThinkFramework extends LibraryInstaller
{
return 'think-framework' === $packageType;
}
}
}

View File

@@ -11,10 +11,9 @@
namespace think\composer;
use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use InvalidArgumentException;
class ThinkTesting extends LibraryInstaller
{
@@ -24,7 +23,7 @@ class ThinkTesting extends LibraryInstaller
public function getInstallPath(PackageInterface $package)
{
if ('topthink/think-testing' !== $package->getPrettyName()) {
throw new \InvalidArgumentException('Unable to install this library!');
throw new InvalidArgumentException('Unable to install this library!');
}
return parent::getInstallPath($package);
@@ -32,19 +31,16 @@ class ThinkTesting extends LibraryInstaller
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
parent::install($repo, $package);
$this->copyTestDir($package);
parent::install($repo, $package)->then(function () use ($package) {
$this->copyTestDir($package);
});
}
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
parent::update($repo, $initial, $target);
$this->copyTestDir($target);
return parent::update($repo, $initial, $target)->then(function () use ($target) {
$this->copyTestDir($target);
});
}
private function copyTestDir(PackageInterface $package)
@@ -65,4 +61,4 @@ class ThinkTesting extends LibraryInstaller
{
return 'think-testing' === $packageType;
}
}
}