Skip to content
This repository was archived by the owner on Dec 13, 2022. It is now read-only.

Commit 72ea6af

Browse files
committed
[FEATURE] Create aliases.json for Symfony Flex support
1 parent 56a8501 commit 72ea6af

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

src/Classes/Command/ExtensionsTerJsonCreateCommand.php

+98-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class ExtensionsTerJsonCreateCommand extends \Symfony\Component\Console\Command\
5151
*/
5252
const JSON_FILE = 'packages-TYPO3Extensions-{type}.json';
5353

54+
/**
55+
* @var string
56+
*/
57+
private const ALIASES_FILE = 'aliases.json';
58+
5459
/**
5560
* @var array
5661
*/
@@ -69,7 +74,7 @@ class ExtensionsTerJsonCreateCommand extends \Symfony\Component\Console\Command\
6974
* prefered over the package created here.
7075
*
7176
* Do not create pull requests for this list, simply provide a
72-
* composer.json for your extension.
77+
* composer.json and register the composer name at TER for your extension.
7378
*
7479
* @var array
7580
*/
@@ -79,6 +84,66 @@ class ExtensionsTerJsonCreateCommand extends \Symfony\Component\Console\Command\
7984
];
8085

8186
/**
87+
* Core extensions
88+
*
89+
* @var array
90+
*/
91+
protected static $coreExtensions = [
92+
'about' => 'typo3/cms-about',
93+
'adminpanel' => 'typo3/cms-adminpanel',
94+
'backend' => 'typo3/cms-backend',
95+
'belog' => 'typo3/cms-belog',
96+
'beuser' => 'typo3/cms-beuser',
97+
'context_help' => 'typo3/cms-context-help',
98+
'core' => 'typo3/cms-core',
99+
'cshmanual' => 'typo3/cms-cshmanual',
100+
'css_styled_content' => 'typo3/cms-css-styled-content',
101+
'documentation' => 'typo3/cms-documentation',
102+
'dashboard' => 'typo3/cms-dashboard',
103+
'extbase' => 'typo3/cms-extbase',
104+
'extensionmanager' => 'typo3/cms-extensionmanager',
105+
'feedit' => 'typo3/cms-feedit',
106+
'felogin' => 'typo3/cms-felogin',
107+
'filelist' => 'typo3/cms-filelist',
108+
'filemetadata' => 'typo3/cms-filemetadata',
109+
'fluid' => 'typo3/cms-fluid',
110+
'fluid_styled_content' => 'typo3/cms-fluid-styled-content',
111+
'form' => 'typo3/cms-form',
112+
'frontend' => 'typo3/cms-frontend',
113+
'func' => 'typo3/cms-func',
114+
'impexp' => 'typo3/cms-impexp',
115+
'indexed_search' => 'typo3/cms-indexed-search',
116+
'info' => 'typo3/cms-info',
117+
'info_pagetsconfig' => 'typo3/cms-info-pagetsconfig',
118+
'install' => 'typo3/cms-install',
119+
'lang' => 'typo3/cms-lang',
120+
'linkvalidator' => 'typo3/cms-linkvalidator',
121+
'lowlevel' => 'typo3/cms-lowlevel',
122+
'opendocs' => 'typo3/cms-opendocs',
123+
'recordlist' => 'typo3/cms-recordlist',
124+
'recycler' => 'typo3/cms-recycler',
125+
'redirects' => 'typo3/cms-redirects',
126+
'reports' => 'typo3/cms-reports',
127+
'rsaauth' => 'typo3/cms-rsaauth',
128+
'rte_ckeditor' => 'typo3/cms-rte-ckeditor',
129+
'saltedpasswords' => 'typo3/cms-saltedpasswords',
130+
'scheduler' => 'typo3/cms-scheduler',
131+
'seo' => 'typo3/cms-seo',
132+
'setup' => 'typo3/cms-setup',
133+
'sv' => 'typo3/cms-sv',
134+
'sys_action' => 'typo3/cms-sys-action',
135+
'sys_note' => 'typo3/cms-sys-note',
136+
't3editor' => 'typo3/cms-t3editor',
137+
'taskcenter' => 'typo3/cms-taskcenter',
138+
'tstemplate' => 'typo3/cms-tstemplate',
139+
'version' => 'typo3/cms-version',
140+
'viewpage' => 'typo3/cms-viewpage',
141+
'wizard_crpages' => 'typo3/cms-wizard-crpages',
142+
'wizard_sortpages' => 'typo3/cms-wizard-sortpages',
143+
'workspaces' => 'typo3/cms-workspaces',
144+
];
145+
146+
/**
82147
* Location where to output built files.
83148
*
84149
* @var string
@@ -109,6 +174,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
109174
$this->outputDir = realpath($input->getArgument('output-dir'));
110175

111176
$this->fetchComposerNames();
177+
$this->saveAliases();
112178
$extensions = $this->getExtensions();
113179
$packages = $this->getPackages($extensions);
114180

@@ -119,6 +185,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
119185
return 0;
120186
}
121187

188+
protected function registerComposerAlias(array $extensionKeys, string $composerName)
189+
{
190+
foreach ($extensionKeys as $extKey) {
191+
if (!isset(self::$abandonedExtensionKeys[$extKey])) {
192+
self::$abandonedExtensionKeys[$extKey] = $composerName;
193+
}
194+
}
195+
}
196+
122197
protected function fetchComposerNames()
123198
{
124199
$client = new Client();
@@ -139,12 +214,34 @@ protected function fetchComposerNames()
139214
}
140215

141216
if (\is_array($json['data'])) {
217+
// Assign core extensions
218+
foreach (self::$coreExtensions as $extKey => $composerName) {
219+
$json['data'][$extKey]['composer_name'] = $composerName;
220+
}
221+
142222
foreach ($json['data'] as $extKey => $settings) {
143223
self::$abandonedExtensionKeys[$extKey] = $settings['composer_name'];
224+
225+
if (strpos($extKey, '_') !== false) {
226+
$this->registerComposerAlias([
227+
\str_replace('_', '-', $extKey),
228+
\str_replace('_', '', $extKey),
229+
], $settings['composer_name']);
230+
}
144231
}
232+
233+
ksort(self::$abandonedExtensionKeys, SORT_STRING);
145234
}
146235
}
147236

237+
protected function saveAliases()
238+
{
239+
$fileName = $this->outputDir . '/' . self::ALIASES_FILE;
240+
file_put_contents($fileName, json_encode(self::$abandonedExtensionKeys));
241+
242+
return $fileName;
243+
}
244+
148245
/**
149246
* @return \SimpleXMLElement[]
150247
*/

src/Classes/Command/SatisBuildCommand.php

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
6565
$output->writeln(sprintf('Running "%s"...', $arguments['command']));
6666
$returnCode = $command->run($commandInput, $output);
6767

68+
// Copy Aliases
69+
if ($returnCode === 0) {
70+
$output->writeln('Copy aliases.json...');
71+
copy(realpath($repositoryDir) . '/aliases.json', realpath($outputDir) . '/aliases.json');
72+
}
73+
6874
// Run satis:json:create
6975
if ($returnCode === 0) {
7076
$command = $this->getApplication()->find('satis:json:create');

0 commit comments

Comments
 (0)