-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Introduce command to create local extension artefact
* [FEATURE] Introduce command to create local extension artefact This commit adds a new `create-artefact` command. It can be used to create a local artefact file (zip archive) of an extension. This is basically the same which is already done in the `ter:publish` command, except for the TER publish part. The new command is especially useful to test custom configurations of package exclude files. In addition, it's a useful helper in cases where the TER REST API might not be accessible. * [TASK] Use different transaction path for `create-artefact` command * [TASK] Include transaction path in exception message * [TASK] Drop AbstractCommand in favor of CommandHelper utility class * [TASK] Use admonitions and create custom section for packaging excludes
- Loading branch information
1 parent
38dbec4
commit 410a9f2
Showing
15 changed files
with
382 additions
and
97 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
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
'bin', | ||
'build', | ||
'public', | ||
'tailor-version-artefact', | ||
'tailor-version-upload', | ||
'tests', | ||
'tools', | ||
|
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
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,88 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 project - inspiring people to share! | ||
* (c) 2020-2023 Oliver Bartsch, Benni Mack & Elias Häußler | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace TYPO3\Tailor\Command\Extension; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use TYPO3\Tailor\Filesystem; | ||
use TYPO3\Tailor\Helper\CommandHelper; | ||
use TYPO3\Tailor\Service\VersionService; | ||
|
||
/** | ||
* Command to create a local extension artefact (zip archive). | ||
*/ | ||
class CreateExtensionArtefactCommand extends Command | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this->setDescription('Create an artefact file (zip archive) of an extension'); | ||
|
||
$this->addArgument( | ||
'version', | ||
InputArgument::REQUIRED, | ||
'The version of the extension, e.g. 1.2.3' | ||
); | ||
$this->addArgument( | ||
'extensionkey', | ||
InputArgument::OPTIONAL, | ||
'The extension key' | ||
); | ||
$this->addOption( | ||
'path', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Path to the extension folder' | ||
); | ||
$this->addOption( | ||
'artefact', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Path or URL to a zip file' | ||
); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
|
||
$version = $input->getArgument('version'); | ||
$extensionKey = CommandHelper::getExtensionKeyFromInput($input); | ||
$path = $input->getOption('path'); | ||
$artefact = $input->getOption('artefact'); | ||
$transactionPath = rtrim(realpath(getcwd() ?: './'), '/') . '/tailor-version-artefact'; | ||
|
||
if (!(new Filesystem\Directory())->create($transactionPath)) { | ||
throw new \RuntimeException(sprintf('Directory could not be created: %s', $transactionPath)); | ||
} | ||
|
||
$versionService = new VersionService($version, $extensionKey, $transactionPath); | ||
|
||
if ($path !== null) { | ||
$versionService->createZipArchiveFromPath($path); | ||
} elseif ($artefact !== null) { | ||
$versionService->createZipArchiveFromArtefact($artefact); | ||
} else { | ||
// If neither `path` nor `artefact` are defined, we just | ||
// create the ZipArchive from the current directory. | ||
$versionService->createZipArchiveFromPath(getcwd() ?: './'); | ||
} | ||
|
||
$io->success(sprintf('Extension artefact successfully generated: %s', $versionService->getVersionFilePath())); | ||
|
||
return 0; | ||
} | ||
} |
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
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
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
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
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
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
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
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
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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 project - inspiring people to share! | ||
* (c) 2020-2024 Oliver Bartsch, Benni Mack & Elias Häußler | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace TYPO3\Tailor\Helper; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use TYPO3\Tailor\Environment\Variables; | ||
use TYPO3\Tailor\Exception\ExtensionKeyMissingException; | ||
use TYPO3\Tailor\Filesystem\ComposerReader; | ||
|
||
/** | ||
* Helper class for console commands. | ||
*/ | ||
final class CommandHelper | ||
{ | ||
public static function getExtensionKeyFromInput(InputInterface $input): string | ||
{ | ||
if ($input->hasArgument('extensionkey') | ||
&& ($key = ($input->getArgument('extensionkey') ?? '')) !== '' | ||
) { | ||
$extensionKey = $key; | ||
} elseif (Variables::has('TYPO3_EXTENSION_KEY')) { | ||
$extensionKey = Variables::get('TYPO3_EXTENSION_KEY'); | ||
} elseif (($extensionKeyFromComposer = (new ComposerReader())->getExtensionKey()) !== '') { | ||
$extensionKey = $extensionKeyFromComposer; | ||
} else { | ||
throw new ExtensionKeyMissingException( | ||
'The extension key must either be set as argument, as environment variable or in the composer.json.', | ||
1605706548 | ||
); | ||
} | ||
|
||
return $extensionKey; | ||
} | ||
} |
Oops, something went wrong.