Commit 06d53e58 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch...

Merge branch '516-add-information-on-uploading-extension-version-without-composer-json' into 'develop'

[TASK] Add information on uploading extension version without composer.json

Closes #516

See merge request !654
parents b79e2fdb 70c26bab
Pipeline #10569 failed with stages
in 7 minutes and 2 seconds
...@@ -523,6 +523,12 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController ...@@ -523,6 +523,12 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
if ($extensionVersion->doesExtensionVersionExist()) { if ($extensionVersion->doesExtensionVersionExist()) {
$this->forwardWithError($this->translate('msg.createVersionVersionExists'), 'uploadVersion'); $this->forwardWithError($this->translate('msg.createVersionVersionExists'), 'uploadVersion');
} }
$composerStatus = '';
if (($composerManifest = $this->getComposerManifest($files)) === []) {
$composerStatus = 'missing';
} elseif (($composerManifest['extra']['typo3/cms']['extension-key'] ?? '') !== $extensionKey) {
$composerStatus = 'missingExtensionKey';
}
$extensionInfo->extensionKey = $extensionKey; $extensionInfo->extensionKey = $extensionKey;
$extensionInfo->infoData->uploadComment = $form['comment']; $extensionInfo->infoData->uploadComment = $form['comment'];
try { try {
...@@ -531,7 +537,7 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController ...@@ -531,7 +537,7 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
$uploader = new ApiUser($this->frontendUser['username']); $uploader = new ApiUser($this->frontendUser['username']);
$uploader->authenticate(); $uploader->authenticate();
$extensionVersion->upload($uploader, $extensionInfo, $files); $extensionVersion->upload($uploader, $extensionInfo, $files);
$this->redirect('index', 'Registerkey', null, ['uploaded' => true], $this->settings['pages']['manageKeysPID']); $this->redirect('index', 'Registerkey', null, ['uploaded' => true, 'composerStatus' => $composerStatus], $this->settings['pages']['manageKeysPID']);
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->forwardWithError('Error ' . $exception->getCode() . ': ' . $exception->getMessage(), 'uploadVersion'); $this->forwardWithError('Error ' . $exception->getCode() . ': ' . $exception->getMessage(), 'uploadVersion');
} }
...@@ -662,4 +668,21 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController ...@@ -662,4 +668,21 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
{ {
return $this->getBaseUrl() . '/' . ExtensionUtility::getExtensionIcon($extension->getExtKey(), $extension->getLastVersion()->getVersionString()); return $this->getBaseUrl() . '/' . ExtensionUtility::getExtensionIcon($extension->getExtKey(), $extension->getLastVersion()->getVersionString());
} }
private function getComposerManifest(array $files): array
{
$composerManifest = [];
foreach ($files as $file) {
$fileName = trim($file->name, '/\\');
if ($fileName === 'composer.json') {
try {
$composerManifest = json_decode(base64_decode($file->content), true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
// Ignore invalid json since this will just return an empty manifest
}
break;
}
}
return $composerManifest;
}
} }
...@@ -75,8 +75,9 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr ...@@ -75,8 +75,9 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr
* Initialize all actions * Initialize all actions
* *
* @param bool $uploaded TRUE if an extension version was successfully uploaded * @param bool $uploaded TRUE if an extension version was successfully uploaded
* @param string $composerStatus Contains information about the composer status, e.g. missing
*/ */
public function indexAction($uploaded = false) public function indexAction(bool $uploaded = false, string $composerStatus = '')
{ {
// get extensions by user if a user is logged in // get extensions by user if a user is logged in
if ($GLOBALS['TSFE']->fe_user->user['uid']) { if ($GLOBALS['TSFE']->fe_user->user['uid']) {
...@@ -89,6 +90,7 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr ...@@ -89,6 +90,7 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr
$this->view->assign('expiringExtensions', $expiringExtensions); $this->view->assign('expiringExtensions', $expiringExtensions);
$this->view->assign('likedExtensions', $likedExtensions); $this->view->assign('likedExtensions', $likedExtensions);
$this->view->assign('uploaded', $uploaded); $this->view->assign('uploaded', $uploaded);
$this->view->assign('composerStatus', $composerStatus);
} }
} }
......
...@@ -246,6 +246,12 @@ ...@@ -246,6 +246,12 @@
<trans-unit id="msg.createVersionUploadSuccess" xml:space="preserve"> <trans-unit id="msg.createVersionUploadSuccess" xml:space="preserve">
<source>Thank you for the upload of your new extension version. It may take up to 15 minutes until it appears in TER.</source> <source>Thank you for the upload of your new extension version. It may take up to 15 minutes until it appears in TER.</source>
</trans-unit> </trans-unit>
<trans-unit id="msg.composerStatus.missing" xml:space="preserve">
<source>Your uploaded extension version does not contain a composer.json file. This will be mandatory in the future.</source>
</trans-unit>
<trans-unit id="msg.composerStatus.missingExtensionKey" xml:space="preserve">
<source>The composer.json of your uploaded extension version does not contain the extension key. This will be mandatory in the future.</source>
</trans-unit>
<trans-unit id="msg.createVersionUploadFailed" xml:space="preserve"> <trans-unit id="msg.createVersionUploadFailed" xml:space="preserve">
<source>Extension upload failed.</source> <source>Extension upload failed.</source>
</trans-unit> </trans-unit>
......
...@@ -10,6 +10,20 @@ ...@@ -10,6 +10,20 @@
</p> </p>
</div> </div>
</f:if> </f:if>
<f:if condition="{composerStatus}">
<div class="alert alert-warning">
<p>
<f:translate key="LLL:EXT:ter_fe2/Resources/Private/Language/locallang.xlf:msg.composerStatus.{composerStatus}" />
More information can be found in the official
<f:link.typolink parameter="https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ComposerJson/Index.html">
TYPO3 documentation
</f:link.typolink>.
</p>
</div>
</f:if>
<header class="mb-4 mt-4"> <header class="mb-4 mt-4">
<h1>Managing my extensions</h1> <h1>Managing my extensions</h1>
</header> </header>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment