diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a4594..180d61d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +2.0.1 +===== + +* (improvement) Disable automatically running janus, as it often fails. +* (improvement) Bump dependencies. + + 2.0.0 ===== diff --git a/composer.json b/composer.json index 53cdeb5..b646a5c 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,13 @@ "php": ">= 8.4", "composer-plugin-api": "^2.6", "21torr/cli": "^1.2.3", - "symfony/console": "^7.3", - "symfony/process": "^7.3" + "symfony/console": "^7.4 || ^8.0", + "symfony/process": "^7.4 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "composer/composer": "^2.8.9", - "phpstan/phpstan": "^2.1.17", + "bamarni/composer-bin-plugin": "^1.8.3", + "composer/composer": "^2.9.4", + "phpstan/phpstan": "^2.1.36", "roave/security-advisories": "dev-latest" }, "autoload": { diff --git a/src/Composer/JanusPlugin.php b/src/Composer/JanusPlugin.php index f79d0ce..f01aa92 100644 --- a/src/Composer/JanusPlugin.php +++ b/src/Composer/JanusPlugin.php @@ -3,7 +3,6 @@ namespace Janus\Composer; use Composer\Composer; -use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\OperationInterface; use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\EventDispatcher\EventSubscriberInterface; @@ -13,9 +12,6 @@ use Composer\Plugin\PluginInterface; use Composer\Script\Event; use Composer\Script\ScriptEvents; -use Janus\Command\InitializeCommand; -use Janus\Package\PackageType; -use Symfony\Component\Process\Process; /** * @final @@ -68,11 +64,6 @@ public function checkForJanusOperations (PackageEvent $event) : void */ private function isJanusUpdate (OperationInterface $operation) : bool { - if ($operation instanceof InstallOperation) - { - return "21torr/janus" === $operation->getPackage()->getName(); - } - if ($operation instanceof UpdateOperation) { return "21torr/janus" === $operation->getTargetPackage()->getName(); @@ -94,91 +85,12 @@ public function afterAutoloadDump (Event $event) : void $this->hadJanusOperation = false; $io = $event->getIO(); - $io->write("\nJanus update detected, running janus update\n"); - - // please note, that the detection can fail: composer defaults to "library", if it's not set - $packageType = PackageType::tryFromComposerType( - $event->getComposer()->getPackage()->getType(), - ); - - if (null === $packageType) - { - $selected = $io->select( - "What are you currently using?", - InitializeCommand::ALLOWED_TYPES, - "library", - ); - $packageType = PackageType::tryFromComposerType(InitializeCommand::ALLOWED_TYPES[$selected] ?? null); - } - else - { - $io->write(\sprintf( - "Detected package type %s", - $packageType->value, - )); - } - - $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); - \assert(\is_string($vendorDir)); - - $success = $this->runJanus($io, $vendorDir, $packageType); - - if ($success) - { - $io->write("\nJanus installation complete.\n"); - } - else - { - $io->writeError("\nJanus installation failed, please run it manually: `composer exec janus init`\n"); - } - } - - /** - * Runs Janus - */ - private function runJanus ( - IOInterface $io, - string $vendorDir, - ?PackageType $type, - ) : bool - { - $command = [ - $this->findJanusExecutable($vendorDir), - "init", - ]; - - if (null !== $type) - { - $command[] = $type->value; - } - - $command[] = "--no-auto-install"; - $command[] = "--ansi"; - - $output = new Process($command); - $output->run( - static function ($type, $buffer) use ($io) : void - { - $io->write($buffer); - }, - ); - - return $output->isSuccessful(); - } - - /** - * Finds the path to the janus executable - */ - private function findJanusExecutable (string $vendorDir) : string - { - // first check if it's installed in the project via composer - if (is_dir("{$vendorDir}/bin/janus")) - { - return "{$vendorDir}/bin/janus"; - } - - // otherwise just fetch the executable from the library and run it - return \dirname(__DIR__, 2) . "/bin/janus"; + $io->write("\nJanus update detected, you need to run janus:\n"); + $io->write("\n"); + $io->write(" ╭───────────────────────────────────────────╮\n"); + $io->write(" │ $ composer exec janus init │\n"); + $io->write(" ╰───────────────────────────────────────────╯\n"); + $io->write("\n"); } /** diff --git a/src/Package/PackageInitializer.php b/src/Package/PackageInitializer.php index 42dad95..6162f6f 100644 --- a/src/Package/PackageInitializer.php +++ b/src/Package/PackageInitializer.php @@ -36,14 +36,14 @@ public function initializeSymfony (ComposerJson $composerJson) : void $composerJson->updateScripts("fix-lint", [ "normalize" => "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi", - "cs-fixer" => "PHP_CS_FIXER_IGNORE_ENV=1 vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi", + "cs-fixer" => "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi", ]); $composerJson->updateScripts("lint", [ "lint:yaml" => "bin/console lint:yaml config --parse-tags", "lint:twig" => "bin/console lint:twig templates", "normalize" => "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi", - "cs-fixer" => "PHP_CS_FIXER_IGNORE_ENV=1 vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi", + "cs-fixer" => "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi", ]); $composerJson->updateScripts("test", [ @@ -77,12 +77,12 @@ public function initializeLibrary (ComposerJson $composerJson) : void $composerJson->updateScripts("fix-lint", [ "normalize" => "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi", - "cs-fixer" => "PHP_CS_FIXER_IGNORE_ENV=1 vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi", + "cs-fixer" => "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi", ]); $composerJson->updateScripts("lint", [ "normalize" => "@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi", - "cs-fixer" => "PHP_CS_FIXER_IGNORE_ENV=1 vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi", + "cs-fixer" => "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi", ]); $composerJson->updateScripts("test", [