Skip to content

Instantly share code, notes, and snippets.

@paul-hansen
Last active September 26, 2023 22:27
Show Gist options
  • Save paul-hansen/ca4850256f7f3ae554e50ef4dc3e7bfd to your computer and use it in GitHub Desktop.
Save paul-hansen/ca4850256f7f3ae554e50ef4dc3e7bfd to your computer and use it in GitHub Desktop.
Bevy 0.11 migration with ast-grep

Bevy 0.11 migration with ast-grep

Uses ast-grep to apply some parts of bevy 0.10 to 0.11 migration that can be automated.

You should review any changes this makes.

cargo install ast-grep
sg -p 'Clicked' --rewrite 'Pressed' -U
sg -p 'LAlt' --rewrite 'AltLeft' -U
sg -p 'LControl' --rewrite 'ControlLeft' -U
sg -p 'RControl' --rewrite 'ControlRight' -U
sg -p 'LShift' --rewrite 'ShiftLeft' -U
sg -p 'RShift' --rewrite 'ShiftRight' -U
sg -p 'RAlt' --rewrite 'AltRight' -U
sg -p 'LWin' --rewrite 'SuperLeft' -U
sg -p 'RWin' --rewrite 'SuperRight' -U
sg -p '$APP.add_startup_system($FOO)' --rewrite '$APP.add_systems(Startup, $FOO)' -U
sg -p '$APP.add_plugin($FOO)' --rewrite '$APP.add_plugins($FOO)' -U
sg -p 'apply_system_buffers' --rewrite 'apply_deferred' -U
sg -p '#[derive($$$PRE, FromReflect $$$POST)]' --rewrite '#[derive($$$PRE, $$$POST)]' -U
sg -p '$APP.add_system($$$FOO)' --rewrite '$APP.add_systems(Update, $$$FOO)' -U
cargo fmt

Helful article for examples on how to construct these patterns: https://betterprogramming.pub/migrating-bevy-can-be-easier-with-semi-automation-here-is-how-1f6e21858e79

Comment below with your own and I'll try to keep this updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment