From 25d774a79c92f303d8836fb8e73f7b321607fbab Mon Sep 17 00:00:00 2001 From: Gilbertsoft <25326036+gilbertsoft@users.noreply.github.com> Date: Sat, 13 Jun 2020 21:37:29 +0200 Subject: [PATCH] [FEATURE] Create aliases.json for Symfony Flex support --- .../ExtensionsTerJsonCreateCommand.php | 88 ++++++++++++++++++- src/Classes/Command/SatisBuildCommand.php | 6 ++ 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/src/Classes/Command/ExtensionsTerJsonCreateCommand.php b/src/Classes/Command/ExtensionsTerJsonCreateCommand.php index d30c334..8b08f23 100644 --- a/src/Classes/Command/ExtensionsTerJsonCreateCommand.php +++ b/src/Classes/Command/ExtensionsTerJsonCreateCommand.php @@ -51,6 +51,11 @@ class ExtensionsTerJsonCreateCommand extends \Symfony\Component\Console\Command\ */ const JSON_FILE = 'packages-TYPO3Extensions-{type}.json'; + /** + * @var string + */ + private const ALIASES_FILE = 'aliases.json'; + /** * @var array */ @@ -69,7 +74,7 @@ class ExtensionsTerJsonCreateCommand extends \Symfony\Component\Console\Command\ * prefered over the package created here. * * Do not create pull requests for this list, simply provide a - * composer.json for your extension. + * composer.json and register the composer name at TER for your extension. * * @var array */ @@ -79,6 +84,66 @@ class ExtensionsTerJsonCreateCommand extends \Symfony\Component\Console\Command\ ]; /** + * Core extensions + * + * @var array + */ + protected static $coreExtensions = [ + 'about' => 'typo3/cms-about', + 'adminpanel' => 'typo3/cms-adminpanel', + 'backend' => 'typo3/cms-backend', + 'belog' => 'typo3/cms-belog', + 'beuser' => 'typo3/cms-beuser', + 'context_help' => 'typo3/cms-context-help', + 'core' => 'typo3/cms-core', + 'cshmanual' => 'typo3/cms-cshmanual', + 'css_styled_content' => 'typo3/cms-css-styled-content', + 'documentation' => 'typo3/cms-documentation', + 'dashboard' => 'typo3/cms-dashboard', + 'extbase' => 'typo3/cms-extbase', + 'extensionmanager' => 'typo3/cms-extensionmanager', + 'feedit' => 'typo3/cms-feedit', + 'felogin' => 'typo3/cms-felogin', + 'filelist' => 'typo3/cms-filelist', + 'filemetadata' => 'typo3/cms-filemetadata', + 'fluid' => 'typo3/cms-fluid', + 'fluid_styled_content' => 'typo3/cms-fluid-styled-content', + 'form' => 'typo3/cms-form', + 'frontend' => 'typo3/cms-frontend', + 'func' => 'typo3/cms-func', + 'impexp' => 'typo3/cms-impexp', + 'indexed_search' => 'typo3/cms-indexed-search', + 'info' => 'typo3/cms-info', + 'info_pagetsconfig' => 'typo3/cms-info-pagetsconfig', + 'install' => 'typo3/cms-install', + 'lang' => 'typo3/cms-lang', + 'linkvalidator' => 'typo3/cms-linkvalidator', + 'lowlevel' => 'typo3/cms-lowlevel', + 'opendocs' => 'typo3/cms-opendocs', + 'recordlist' => 'typo3/cms-recordlist', + 'recycler' => 'typo3/cms-recycler', + 'redirects' => 'typo3/cms-redirects', + 'reports' => 'typo3/cms-reports', + 'rsaauth' => 'typo3/cms-rsaauth', + 'rte_ckeditor' => 'typo3/cms-rte-ckeditor', + 'saltedpasswords' => 'typo3/cms-saltedpasswords', + 'scheduler' => 'typo3/cms-scheduler', + 'seo' => 'typo3/cms-seo', + 'setup' => 'typo3/cms-setup', + 'sv' => 'typo3/cms-sv', + 'sys_action' => 'typo3/cms-sys-action', + 'sys_note' => 'typo3/cms-sys-note', + 't3editor' => 'typo3/cms-t3editor', + 'taskcenter' => 'typo3/cms-taskcenter', + 'tstemplate' => 'typo3/cms-tstemplate', + 'version' => 'typo3/cms-version', + 'viewpage' => 'typo3/cms-viewpage', + 'wizard_crpages' => 'typo3/cms-wizard-crpages', + 'wizard_sortpages' => 'typo3/cms-wizard-sortpages', + 'workspaces' => 'typo3/cms-workspaces', + ]; + + /** * Location where to output built files. * * @var string @@ -109,6 +174,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->outputDir = realpath($input->getArgument('output-dir')); $this->fetchComposerNames(); + $this->saveAliases(); $extensions = $this->getExtensions(); $packages = $this->getPackages($extensions); @@ -139,12 +205,32 @@ protected function fetchComposerNames() } if (\is_array($json['data'])) { + // Assign core extensions + foreach (self::$coreExtensions as $extKey => $composerName) { + $json['data'][$extKey]['composer_name'] = $composerName; + } + foreach ($json['data'] as $extKey => $settings) { self::$abandonedExtensionKeys[$extKey] = $settings['composer_name']; + + if (strpos($extKey, '_') !== false) { + self::$abandonedExtensionKeys[\str_replace('_', '-', $extKey)] = $settings['composer_name']; + self::$abandonedExtensionKeys[\str_replace('_', '', $extKey)] = $settings['composer_name']; + } } + + ksort(self::$abandonedExtensionKeys, SORT_STRING); } } + protected function saveAliases() + { + $fileName = $this->outputDir . '/' . self::ALIASES_FILE; + file_put_contents($fileName, json_encode(self::$abandonedExtensionKeys)); + + return $fileName; + } + /** * @return \SimpleXMLElement[] */ diff --git a/src/Classes/Command/SatisBuildCommand.php b/src/Classes/Command/SatisBuildCommand.php index c6fb2f1..fb210b4 100644 --- a/src/Classes/Command/SatisBuildCommand.php +++ b/src/Classes/Command/SatisBuildCommand.php @@ -65,6 +65,12 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('Running "%s"...', $arguments['command'])); $returnCode = $command->run($commandInput, $output); + // Copy Aliases + if ($returnCode === 0) { + $output->writeln('Copy aliases.json...'); + copy(realpath($repositoryDir) . '/aliases.json', realpath($outputDir) . '/aliases.json'); + } + // Run satis:json:create if ($returnCode === 0) { $command = $this->getApplication()->find('satis:json:create');