Open
Conversation
- Added a new `Upgrader::isUpgraded` method to determine if the named upgrade has already been completed. - Replaced the direct config access in the Upgrader methods `shouldUpgradeSymbolicLinks` and `shouldUpgradeNginxSitePhpPortOverrides` to use the new `isUpgraded` method. - Refactored `Configuration::updateKey` method to use Laravel's `Arr::set` method to set a value within an array instead of the direct array access. It enables usage of dot notation to easily access deeply nested array keys.
- Added a new `Upgrader::markAsUpgraded` method to mark an upgrade as completed, and add a key into Valet's config. - Replaced the direct config `updateKey` in the Upgrader methods `upgradeSymbolicLinks` and `upgradeNginxSitePhpPortOverrides` to use the new `markAsUpgraded` method.
- Replaced the `shouldUpgradeNginxSitePhpPortOverrides` method call with a direct call to `isUpgraded` method for improved clarity and conciseness. The former method was only a light wrapper around `isUpgraded` method anyway. - Removed the now unused `shouldUpgradeNginxSitePhpPortOverrides` method.
The new format allows for multiple one-time upgrade keys to be stored in an organised manner under the `upgrades` array. This stops valet's config from being polluted with many top-level `*_upgraded` config keys when new one-time upgrades are added in the future. - Changed the `symlinks_upgraded` key to `symlinks`. - Changed the `php_port_overrides_upgraded` key to `nginx_site_php_port_overrides`. - Changed the config `get` and `updateKey` calls in `isUpgraded` and `markAsUpgraded` methods to use dot notation to get/update the specified upgrade key from the new top-level `upgrades`.
- Added `Upgrader::migrateSymlinksUpgradeKey` method to handle the transition from `symlinks_upgraded` to `symlinks`. Note: The `symlinks_upgraded` is the only legacy key that needs to be migrated. The `php_port_overrides_upgraded` key wasn't released in a stable version, so it doesn't need migrating. - Added `Configuration::removeKey` method to remove a specified key from the config.
- Changed the `hasNewKey` variable value in `migrateSymlinksUpgradeKey` method to use the `isUpgraded` method since it does the same job.
- Replace `shouldUpgradeSymbolicLinks` method with inline condition to check if symlinks have not been upgraded and if the sites directory is not empty. - Removed the now unused `shouldUpgradeSymbolicLinks` method.
…ctor/restructure-upgrade-keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how upgrade state is tracked in the configuration, consolidating upgrade keys under a single
upgradesarray and improving configuration key management. The changes also add helper methods for manipulating nested configuration keys using Laravel's array helpers.Configuration management improvements:
Added
removeKeymethod inConfiguration.phpto remove nested configuration values using Laravel'sArr::forgethelper, allowing for dot notation.Changed
updateKeymethod inConfiguration.phpto use Laravel'sArr::sethelper, allowing for dot notation and more flexible configuration updates.Upgrade state tracking refactor:
Consolidated upgrade keys (such as
symlinks_upgradedandphp_port_overrides_upgraded) under a newupgradesarray in the configuration, with new namessymlinksandnginx_site_php_port_overrides.Added new helper methods
isUpgradedandmarkAsUpgradedto access the newupgradesconfig format and improve upgrade tracking consistency.Added a migration method (
migrateSymlinksUpgradeKey) to move the legacysymlinks_upgradedkey to the newupgrades.symlinkskey and clean up the old key, ensuring backward compatibility and config cleanliness. This prevents the breaking change from being a breaking change.Note: The
symlinks_upgradedis the only legacy key that needs to be migrated. Thephp_port_overrides_upgradedkey wasn't released in a stable version, so it doesn't need migrating.Replaced the
shouldUpgradeNginxSitePhpPortOverridesandshouldUpgradeSymbolicLinksmethod calls with a direct call toisUpgradedmethod.Removed the now unused
shouldUpgradeNginxSitePhpPortOverridesandshouldUpgradeSymbolicLinksmethods.These changes make the upgrade process more robust and future proof and the configuration file easier to maintain.