aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2024-03-06 11:09:50 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2024-03-06 11:16:10 +0100
commitf0494e2b5a8c56cf63f9a74a65e38344627dad2a (patch)
treecf985ada5c0a8d44eff50fcdc7ca3ca364fd16aa /apps/settings/lib
parent80e4193d4ff292733d68253169f29847c295e424 (diff)
downloadnextcloud-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')
-rw-r--r--apps/settings/lib/AppInfo/Application.php2
-rw-r--r--apps/settings/lib/SetupChecks/JavaScriptSourceMaps.php68
2 files changed, 70 insertions, 0 deletions
diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php
index 6ff31ae68f7..12cd21cf17c 100644
--- a/apps/settings/lib/AppInfo/Application.php
+++ b/apps/settings/lib/AppInfo/Application.php
@@ -67,6 +67,7 @@ use OCA\Settings\SetupChecks\ForwardedForHeaders;
use OCA\Settings\SetupChecks\HttpsUrlGeneration;
use OCA\Settings\SetupChecks\InternetConnectivity;
use OCA\Settings\SetupChecks\JavaScriptModules;
+use OCA\Settings\SetupChecks\JavaScriptSourceMaps;
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
use OCA\Settings\SetupChecks\MaintenanceWindowStart;
use OCA\Settings\SetupChecks\MemcacheConfigured;
@@ -193,6 +194,7 @@ class Application extends App implements IBootstrap {
$context->registerSetupCheck(ForwardedForHeaders::class);
$context->registerSetupCheck(HttpsUrlGeneration::class);
$context->registerSetupCheck(InternetConnectivity::class);
+ $context->registerSetupCheck(JavaScriptSourceMaps::class);
$context->registerSetupCheck(JavaScriptModules::class);
$context->registerSetupCheck(LegacySSEKeyFormat::class);
$context->registerSetupCheck(MaintenanceWindowStart::class);
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.'));
+ }
+}