azriel91 / peace

Zero Stress Automation
https://peace.mk
Apache License 2.0
110 stars 1 forks source link

Update dependencies and use workspace dependencies #128

Closed azriel91 closed 1 year ago

azriel91 commented 1 year ago

Maintenance ticket to:

azriel91 commented 1 year ago
Script for using [workspace.package] for crate metadata ```bash # Replace package fields fd -Ftf Cargo.toml --exclude examples -x sd '^version = "0\.0\.10"$' 'version.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd -s 'authors = ["Azriel Hoh "]' 'authors.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd -s 'edition = "2021"' 'edition.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd -s 'repository = "https://github.com/azriel91/peace"' 'repository.workspace = true homepage.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd '^readme = .+' 'readme.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd '^categories = .+' 'categories.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd '^keywords = .+' 'keywords.workspace = true' fd -Ftf Cargo.toml --exclude examples -x sd '^license = .+' 'license.workspace = true' # Move description and documentation fields under `name` fd -Ftf Cargo.toml --exclude examples -x bash -c " cat << EOF | ed -sE {} /^name/ ka /^description/ m'a ka /^documentation/ m'a w EOF " ```
Script to extract crates to put into [workspace.dependencies] :warning: **Note:** Still had to manually edit by hand, and add the remainder of peace crates. ```bash # Find dependencies in all `Cargo.toml`s fd -Ftf Cargo.toml --exclude examples -x \ rg '^[a-zA-Z0-9_-]+ = (("[0-9.]+")|[{])' | \ rg -v '^(version|edition)' | \ sort | \ uniq | \ xclip -se c ```
Script used to change Cargo.tomls to point to [workspace.dependencies] ```bash # Replace `peace` dependencies in `Cargo.toml`s fd -Ftf Cargo.toml --exclude examples -x \ sd '\{ path = "([a-z_/.]+)", version = "0\.0\.10"([^}]+)\}' '{ workspace = true$2}' fd -Ftf Cargo.toml --exclude examples -x \ sd '\{ version = "0\.0\.10", path = "([a-z_/.]+)"([^}]+)\}' '{ workspace = true$2}' # Replace simple version dependencies in `Cargo.toml`s fd -Ftf Cargo.toml --exclude examples -x \ sd '^([a-z-_0-9]+) = ("[0-9.]+")' '$1 = { workspace = true }' # Replace complex version dependencies in `Cargo.toml`s fd -Ftf Cargo.toml --exclude examples -x \ sd '^([a-z-_0-9]+) = \{ version = "[0-9.]+"([^}]+)\}' '$1 = { workspace = true$2}' # Put back version and edition values fd -Ftf Cargo.toml --exclude examples -x sd -s 'edition = { workspace = true }' 'edition = "2021"' sd -s 'version = { workspace = true }' 'version = "0.0.10"' Cargo.toml ```