diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2024-03-06 11:09:50 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2024-03-06 11:16:10 +0100 |
commit | f0494e2b5a8c56cf63f9a74a65e38344627dad2a (patch) | |
tree | cf985ada5c0a8d44eff50fcdc7ca3ca364fd16aa /apps/settings/lib/SetupChecks | |
parent | 80e4193d4ff292733d68253169f29847c295e424 (diff) | |
download | nextcloud-server-f0494e2b5a8c56cf63f9a74a65e38344627dad2a.tar.gz nextcloud-server-f0494e2b5a8c56cf63f9a74a65e38344627dad2a.zip |
feat(settings): add JavaScript Source Maps support `.js.map` setup check
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/settings/lib/SetupChecks')
-rw-r--r-- | apps/settings/lib/SetupChecks/JavaScriptSourceMaps.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/apps/settings/lib/SetupChecks/JavaScriptSourceMaps.php b/apps/settings/lib/SetupChecks/JavaScriptSourceMaps.php new file mode 100644 index 00000000000..b116d90f64f --- /dev/null +++ b/apps/settings/lib/SetupChecks/JavaScriptSourceMaps.php @@ -0,0 +1,68 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2024 John Molakvoæ <skjnldsv@protonmail.com> + * + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCA\Settings\SetupChecks; + +use OCP\Http\Client\IClientService; +use OCP\IConfig; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; +use Psr\Log\LoggerInterface; + +/** + * Checks if the webserver serves '.map' files using the correct MIME type + */ +class JavaScriptSourceMaps implements ISetupCheck { + use CheckServerResponseTrait; + + public function __construct( + protected IL10N $l10n, + protected IConfig $config, + protected IURLGenerator $urlGenerator, + protected IClientService $clientService, + protected LoggerInterface $logger, + ) { + } + + public function getCategory(): string { + return 'network'; + } + + public function getName(): string { + return $this->l10n->t('JavaScript Source Maps support'); + } + + public function run(): SetupResult { + $testFile = $this->urlGenerator->linkTo('settings', 'js/map-test.js.map'); + + foreach ($this->runHEAD($testFile) as $response) { + return SetupResult::success(); + } + + return SetupResult::error($this->l10n->t('Your webserver is not set up to serve `.js.map` files. Without these files, JavaScript Source Maps won\'t function properly, making it more challenging to troubleshoot and debug any issues that may arise.')); + } +} |