Skip to content

Conversation

pirs1337
Copy link
Contributor

refs: #38

@pirs1337 pirs1337 self-assigned this Sep 22, 2025
@coveralls
Copy link

coveralls commented Sep 22, 2025

Pull Request Test Coverage Report for Build 18311554711

Details

  • 27 of 34 (79.41%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-2.0%) to 95.95%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ConfigWriter/ArrayPrinter.php 8 11 72.73%
src/ConfigWriter/ArrayFile.php 12 16 75.0%
Totals Coverage Status
Change from base Build 18301590721: -2.0%
Covered Lines: 308
Relevant Lines: 321

💛 - Coveralls

@pirs1337 pirs1337 assigned DenTray and unassigned pirs1337 Sep 22, 2025
@DenTray DenTray requested a review from Copilot September 23, 2025 06:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates Laravel Telescope middleware configuration from default authorization to web authentication. The change replaces the Telescope-specific Authorize::class middleware with 'auth:web' for telescope route access control.

  • Replaces Telescope authorization middleware with web authentication
  • Removes unused Authorize middleware import from telescope config
  • Updates all test fixtures to reflect the middleware change

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Commands/InitCommand.php Adds method to replace Telescope Authorize middleware with auth:web
tests/InitCommandTest.php Updates test expectations to mock telescope config file operations
tests/fixtures/InitCommandTest/origin_telescope_config.php Original telescope config with Authorize middleware
tests/fixtures/InitCommandTest/updated_telescope_config.php Updated telescope config with auth:web middleware

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


protected function changeMiddlewareForTelescopeAuthorization(): void
{
$telescopeConfigPath = base_path('/config/telescope.php');
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the leading slash from the path. The base_path() function expects a relative path, and including a leading slash can cause issues on different operating systems.

Suggested change
$telescopeConfigPath = base_path('/config/telescope.php');
$telescopeConfigPath = base_path('config/telescope.php');

Copilot uses AI. Check for mistakes.

Comment on lines 583 to 586
$content = Str::replace('Authorize::class', "'auth:web'", file_get_contents($telescopeConfigPath));
$content = Str::replace("use Laravel\Telescope\Http\Middleware\Authorize;\n", '', $content);

file_put_contents($telescopeConfigPath, $content);
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string replacement approach is fragile and could fail if the telescope config format changes. Consider using a more robust approach like parsing the PHP array structure or checking if the file exists before performing replacements.

Suggested change
$content = Str::replace('Authorize::class', "'auth:web'", file_get_contents($telescopeConfigPath));
$content = Str::replace("use Laravel\Telescope\Http\Middleware\Authorize;\n", '', $content);
file_put_contents($telescopeConfigPath, $content);
$config = ArrayFile::load($telescopeConfigPath);
// Update the 'middleware' key to use 'auth:web'
if (isset($config['middleware'])) {
$config['middleware'] = ['auth:web'];
}
ArrayFile::save($telescopeConfigPath, $config);

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pirs1337 please use already installed library for updating config files, here is example

protected function setAutoDocContactEmail(string $email): void

Comment on lines 583 to 586
$content = Str::replace('Authorize::class', "'auth:web'", file_get_contents($telescopeConfigPath));
$content = Str::replace("use Laravel\Telescope\Http\Middleware\Authorize;\n", '', $content);

file_put_contents($telescopeConfigPath, $content);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pirs1337 please use already installed library for updating config files, here is example

protected function setAutoDocContactEmail(string $email): void

@DenTray DenTray assigned pirs1337 and unassigned DenTray Sep 23, 2025
…iddleware

# Conflicts:
#	src/Commands/InitCommand.php
#	tests/InitCommandTest.php
#	tests/Support/Traits/InitCommandMockTrait.php
@pirs1337 pirs1337 assigned DenTray and unassigned pirs1337 Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants