Skip to content

Commit

Permalink
Handle new report boolean in filesystems config (#122)
Browse files Browse the repository at this point in the history
* Migrate with new `’report’ => false` default.

* Update assertion strings.

* Update normalization methods.

* Up ‘until’.

* Fix whitespace.
  • Loading branch information
jesseleite authored Jan 23, 2025
1 parent 0854880 commit 719e408
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/AssetContainerMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ protected function localDiskConfig()
'url' => "/{$path}",
'visibility' => 'public',
'throw' => false,
'report' => false,
];
}

Expand All @@ -348,6 +349,7 @@ protected function s3DiskConfig()
'endpoint' => "env('{$envPrefix}_AWS_ENDPOINT')",
'use_path_style_endpoint' => "env('{$envPrefix}_AWS_USE_PATH_STYLE_ENDPOINT', false)",
'throw' => false,
'report' => false,
];
}

Expand Down
64 changes: 64 additions & 0 deletions tests/MigrateAssetContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public function it_migrates_disk_with_local_driver()
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'report' => false,
],
'public' => [
Expand All @@ -309,6 +310,7 @@ public function it_migrates_disk_with_local_driver()
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
Expand All @@ -321,6 +323,7 @@ public function it_migrates_disk_with_local_driver()
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
'assets' => [
Expand All @@ -329,6 +332,7 @@ public function it_migrates_disk_with_local_driver()
'url' => '/assets',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
],
Expand Down Expand Up @@ -367,6 +371,7 @@ public function it_migrates_disk_with_s3_driver()
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'report' => false,
],
'public' => [
Expand All @@ -375,6 +380,7 @@ public function it_migrates_disk_with_s3_driver()
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
Expand All @@ -387,6 +393,7 @@ public function it_migrates_disk_with_s3_driver()
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
'assets' => [
Expand All @@ -399,6 +406,7 @@ public function it_migrates_disk_with_s3_driver()
'endpoint' => env('ASSETS_AWS_ENDPOINT'),
'use_path_style_endpoint' => env('ASSETS_AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
Expand All @@ -419,6 +427,7 @@ public function it_migrates_disk_with_terser_key_when_assets_already_exists()
'driver' => 'local',
'root' => "storage_path('app/some-other-user-assets-unrelated-to-statamic')",
'throw' => false,
'report' => false,
],
]);

Expand All @@ -431,6 +440,7 @@ public function it_migrates_disk_with_terser_key_when_assets_already_exists()
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'report' => false,
],
'public' => [
Expand All @@ -439,6 +449,7 @@ public function it_migrates_disk_with_terser_key_when_assets_already_exists()
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
Expand All @@ -451,12 +462,14 @@ public function it_migrates_disk_with_terser_key_when_assets_already_exists()
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
'assets' => [
'driver' => 'local',
'root' => storage_path('app/some-other-user-assets-unrelated-to-statamic'),
'throw' => false,
'report' => false,
],
'assets_main' => [
Expand All @@ -465,6 +478,7 @@ public function it_migrates_disk_with_terser_key_when_assets_already_exists()
'url' => '/assets/main',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
],
Expand Down Expand Up @@ -501,6 +515,7 @@ public function it_migrates_multiple_disks_with_terser_keys_only()
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'report' => false,
],
'public' => [
Expand All @@ -509,6 +524,7 @@ public function it_migrates_multiple_disks_with_terser_keys_only()
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
Expand All @@ -521,6 +537,7 @@ public function it_migrates_multiple_disks_with_terser_keys_only()
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
'assets_main' => [
Expand All @@ -529,6 +546,7 @@ public function it_migrates_multiple_disks_with_terser_keys_only()
'url' => '/assets/main',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
'assets_cloud' => [
Expand All @@ -541,6 +559,7 @@ public function it_migrates_multiple_disks_with_terser_keys_only()
'endpoint' => env('ASSETS_CLOUD_AWS_ENDPOINT'),
'use_path_style_endpoint' => env('ASSETS_CLOUD_AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
Expand Down Expand Up @@ -576,13 +595,15 @@ public function it_overwrites_disks_when_forced()
'url' => '/assets/main/edited-route',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
'assets_cloud' => [
'driver' => 'local',
'root' => public_path('assets/cloud'),
'url' => '/assets/cloud/edited-route',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
])
->refresh();
Expand All @@ -600,6 +621,7 @@ public function it_overwrites_disks_when_forced()
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'report' => false,
],
'public' => [
Expand All @@ -608,6 +630,7 @@ public function it_overwrites_disks_when_forced()
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
Expand All @@ -620,6 +643,7 @@ public function it_overwrites_disks_when_forced()
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
'assets_main' => [
Expand All @@ -628,6 +652,7 @@ public function it_overwrites_disks_when_forced()
'url' => '/assets/main',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
'assets_cloud' => [
Expand All @@ -640,6 +665,7 @@ public function it_overwrites_disks_when_forced()
'endpoint' => env('ASSETS_CLOUD_AWS_ENDPOINT'),
'use_path_style_endpoint' => env('ASSETS_CLOUD_AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
Expand Down Expand Up @@ -762,12 +788,22 @@ protected function normalizeLocalConfig($config)
],
EOT;

// Up until Laravel 11.39
$variants[] = <<<'EOT'
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
EOT;

// Current version
$current = <<<'EOT'
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
'report' => false,
],
EOT;

Expand Down Expand Up @@ -795,6 +831,17 @@ protected function normalizePublicConfig($config)
],
EOT;

// Up until Laravel 11.39
$variants[] = <<<'EOT'
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
EOT;

// Current version
$current = <<<'EOT'
'public' => [
Expand All @@ -803,6 +850,7 @@ protected function normalizePublicConfig($config)
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
EOT;

Expand Down Expand Up @@ -847,6 +895,21 @@ protected function normalizeS3Config($config)
],
EOT;

// Up until Laravel 11.39
$variants[] = <<<'EOT'
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
EOT;

// Current version
$current = <<<'EOT'
's3' => [
Expand All @@ -859,6 +922,7 @@ protected function normalizeS3Config($config)
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
EOT;

Expand Down

0 comments on commit 719e408

Please sign in to comment.