Why
Based on many conversations over the years regarding one-off scripts best practices, I want to introduce a new UI experience for the /script folder. Much akin to the wonderful MailerPreviews UI.
What
This feature would implement several items:
- Display a listing of all available scripts that can be run
- Show an individual script page
- Enable manual running of the script
- Enable viewing of script source code
- Enable ephemeral script output results
- Enable form submission disable state to prevent individual users from re-running scripts
- Enable cache-based lock for currently running scripts to avoid multiplicative effects from multiple users
- Provide a configuration to constrain script generated routes behind host implemented authorization (using: Rails Routing from the Outside In — Ruby on Rails Guides )
- The configuration would allow authorized multi-environment running of scripts
If there is interest in a script UI, I’ve got a spike in progress for implementation and would love to get feedback on it.
Benefits
- Makes scripts more visible and gives a dedicated UI to run them
- Allows team members without
rails consolepermission to run available scripts - Follows along with established pattern of MailerPreviews in terms of routing and style
- Leans into making scripts a default location for one-off scripts
- Can run in any environment
- Prevents multiplicative effect (via lock) of two users trying to run the same script at the same time
Downsides
- Can run in any environment (benefit as well) which means that the auth logic needs to be solid
- Uses cache for storing output and locking script (would have short expires at)
- No script stopping mechanism (no different than running it directly in CI though)
- Good use-case for using maintenance tasks instead
Discussions: