Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Allow excluding features from purge command #89

Merged
merged 4 commits into from
Mar 4, 2024
Merged

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Mar 4, 2024

Re-implementation of #87

Documentation: laravel/docs#9448

Allows for excluding features from the purge command. This command now has the following API:

# Purge everything from storage (already exists)

php artisan pennant:purge

# Purge specific features from storage (already exists)

php artisan pennant:purge foo bar

# Purge all features from storage except those specified (new ✨)

php artisan pennant:purge --except=foo --except=bar

# Purge all features from storage except those registered (new ✨)

php artisan pennant:purge --except-registered

--except-registered?

You could run this on deploy to clear out feature flags you no longer use.

Warning

Pennant allows you to dynamically register features, i.e., they don't have to be defined in a service provider. If you use this flag it may clear features you still use in your application if you are using dynamic registration.

Use in combination

The command handles using all of these in combination, e.g., it will be able to handle the following...

php artisan pennant:purge foo bar --except=bar --except-registered

The excepts will always take precedence and ensure that any features found in that list are not purged, even if they are explicitly passed to the command like we did with foo and bar.

3rd party drivers

Drivers should implement the CanListStoredFeatures interface if they wish to support these new features. This contract adds a single new method, stored, which returns a unique list of stored feature names - similar to the defined interface method which returns a unique list of all the defined feature names.

Comment on lines -394 to +410
$this->driver->purge($features);
$this->driver->purge($features->all());
Copy link
Member Author

Choose a reason for hiding this comment

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

These methods support collections, but are typed to expect arrays. Fixing this while I notice it.

Comment on lines -89 to +90
* Define the names of all defined features.
* Retrieve the names of all defined features.
Copy link
Member Author

Choose a reason for hiding this comment

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

Typo here. Now matches the interface's comment.

Comment on lines -32 to +34
class Decorator implements DriverContract
class Decorator implements CanListStoredFeatures, Driver
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the useless Contract suffix here to match the other drivers.

@timacdonald timacdonald marked this pull request as ready for review March 4, 2024 03:40
@taylorotwell taylorotwell merged commit b3783b0 into 1.x Mar 4, 2024
7 checks passed
@taylorotwell taylorotwell deleted the prune branch March 4, 2024 14:13
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.

2 participants