1
0

JavaScriptSourceMaps.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\Http\Client\IClientService;
  9. use OCP\IConfig;
  10. use OCP\IL10N;
  11. use OCP\IURLGenerator;
  12. use OCP\SetupCheck\CheckServerResponseTrait;
  13. use OCP\SetupCheck\ISetupCheck;
  14. use OCP\SetupCheck\SetupResult;
  15. use Psr\Log\LoggerInterface;
  16. /**
  17. * Checks if the webserver serves '.map' files using the correct MIME type
  18. */
  19. class JavaScriptSourceMaps implements ISetupCheck {
  20. use CheckServerResponseTrait;
  21. public function __construct(
  22. protected IL10N $l10n,
  23. protected IConfig $config,
  24. protected IURLGenerator $urlGenerator,
  25. protected IClientService $clientService,
  26. protected LoggerInterface $logger,
  27. ) {
  28. }
  29. public function getCategory(): string {
  30. return 'network';
  31. }
  32. public function getName(): string {
  33. return $this->l10n->t('JavaScript source map support');
  34. }
  35. public function run(): SetupResult {
  36. $testFile = $this->urlGenerator->linkTo('settings', 'js/map-test.js.map');
  37. foreach ($this->runRequest('HEAD', $testFile) as $response) {
  38. return SetupResult::success();
  39. }
  40. return SetupResult::warning($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.'));
  41. }
  42. }