From 260188dc89513959f622e011f5b64d0ff40df32f Mon Sep 17 00:00:00 2001 From: Trey Lowerison <19714082+tlowerison@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:49:35 -0700 Subject: [PATCH] configure git-cliff, release-plz, dependabot, and mergify --- .github/dependabot.yml | 15 +++++ .github/mergify.yml | 15 +++++ .github/workflows/release-plz.yml | 26 +++++++++ Cargo.toml | 25 +++++++++ README.md | 91 ++++++++++++++++++++++++++++++- cliff.toml | 83 ++++++++++++++++++++++++++++ core/Cargo.toml | 2 +- leptos_form/Cargo.toml | 5 +- leptos_form/Crate.md | 90 +----------------------------- proc_macros/Cargo.toml | 3 +- proc_macros/core/Cargo.toml | 1 + release-plz.toml | 27 +++++++++ 12 files changed, 289 insertions(+), 94 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/mergify.yml create mode 100644 .github/workflows/release-plz.yml create mode 100644 cliff.toml mode change 100644 => 120000 leptos_form/Crate.md create mode 100644 release-plz.toml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0b4dd78 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + # Maintain dependencies for Cargo + - package-ecosystem: cargo + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + + # Maintain dependencies for GitHub Actions + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/mergify.yml b/.github/mergify.yml new file mode 100644 index 0000000..5038fc8 --- /dev/null +++ b/.github/mergify.yml @@ -0,0 +1,15 @@ +pull_request_rules: + - name: Automatic merge for Dependabot pull requests + conditions: + - author=dependabot[bot] + actions: + merge: + method: squash + + - name: Automatic update to the main branch for pull requests + conditions: + - -conflict # skip PRs with conflicts + - -draft # skip GH draft PRs + - -author=dependabot[bot] # skip dependabot PRs + actions: + update: diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml new file mode 100644 index 0000000..7f6d474 --- /dev/null +++ b/.github/workflows/release-plz.yml @@ -0,0 +1,26 @@ +name: Continuous Deployment + +on: + push: + branches: + - main + +jobs: + release-plz: + name: Release-plz + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.RELEASE_PLZ_TOKEN }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Run release-plz + uses: MarcoIeni/release-plz-action@v0.5 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 88ca532..85e983d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,15 @@ resolver = "2" version = "0.1.0" edition = "2021" authors = ["Trey Lowerison <19714082+tlowerison@users.noreply.github.com>"] +repository = "https://github.com/tlowerison/leptos_form" [workspace.dependencies] +# internal to this workspace +# update these versions along with the workspace version +leptos_form_core = { version = "0.1.0", path = "core" } +leptos_form_proc_macros = { version = "0.1.0", path = "proc_macros" } +leptos_form_proc_macros_core = { version = "0.1.0", path = "proc_macros/core" } + bigdecimal = "~0.4" chrono = { version = "0", features = ["std"] } convert_case = "~0.6" @@ -32,3 +39,21 @@ typed-builder = "~0.16" uuid = { version = "1", features = ["serde"] } wasm-bindgen = "~0.2" web-sys = "~0.3" + +# Config for 'cargo dist' +[workspace.metadata.dist] +# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) +cargo-dist-version = "0.4.2" +# CI backends to support +ci = ["github"] +# The installers to generate for each app +installers = [] +# Target platforms to build apps for (Rust target-triple syntax) +targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +# Publish jobs to run in CI +pr-run-mode = "plan" + +# The profile that 'cargo dist' will build with +[profile.dist] +inherits = "release" +lto = "thin" diff --git a/README.md b/README.md index a9e4fd0..81666ce 100644 --- a/README.md +++ b/README.md @@ -1 +1,90 @@ -# leptos_form +# leptos_form: Derive leptos forms from rust structs + +
+ + + + + + + + + + + + + + + + + + + +
+ +## Documentation + +* [Docs](https://docs.rs/leptos_form) +* [GitHub repository](https://github.com/tlowerison/leptos_form) +* [Cargo package](https://crates.io/crates/leptos_form) + +## Features + +* Automatic form parsing -- focus on how your data is represented and not on how to get it in and out of html +* Easy specification of label and input classes, great for Tailwind integration +* Labels are derived from struct fields and can be given form-wide casing +* DOM layout customization through attributes +* Integration with popular crates + +## Crate features + +This crate offers the following features, all of which are not activated by default: + +- `bigdecimal`: Provides impls for [`BigDecimal`](https://docs.rs/bigdecimal/latest/bigdecimal/struct.BigDecimal.html) +- `chrono`: Provides impls for [`DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html), [`NaiveDate`](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDate.html), [`NaiveDateTime`](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDateTime.html) +- `num-bigint`: Provides impls for [`BigInt`](https://docs.rs/num-bigint/latest/num_bigint/struct.BigInt.html) and [`BigUint`](https://docs.rs/num-bigint/latest/num_bigint/struct.BigUint.html) +- `uuid`: Provides impls for [`Uuid`](https://docs.rs/uuid/latest/uuid/struct.Uuid.html) + +## Example + +```rust +mod my_crate { + use leptos::*; + use leptos_form::prelude::*; + use serde::*; + + #[derive(Clone, Debug, Default, Deserialize, Form, Serialize)] + #[form( + component( + action = create_my_data(my_data), + submit = view!(), + on_success = |DbMyData { id, .. }, _| view!(
{format!("Created {id}")}
), + reset_on_success, + ), + label(wrap(class = "my-class", rename_all = "Title Case")), + )] + pub struct MyData { + pub my_name: String, + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct DbMyData { + pub id: i32, + pub name: String, + } + + #[component] + pub fn MyComponent() -> impl IntoView { + view!() + } + + #[server] + async fn create_my_data(my_data: MyData) -> Result { + todo!() + } +} +``` diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..7beeaca --- /dev/null +++ b/cliff.toml @@ -0,0 +1,83 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for commit in commits %} + - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# remove the leading and trailing whitespace from the template +trim = true +# changelog footer +footer = """ + +""" +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, # replace issue numbers +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "Features" }, + { message = "^fix", group = "Bug Fixes" }, + { message = "^doc", group = "Documentation" }, + { message = "^perf", group = "Performance" }, + { message = "^refactor", group = "Refactor" }, + { message = "^style", group = "Styling" }, + { message = "^test", group = "Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|ci", group = "Miscellaneous Tasks" }, + { body = ".*security", group = "Security" }, + { message = "^revert", group = "Revert" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +tag_pattern = "v[0-9].*" + +# regex for skipping tags +skip_tags = "v0.1.0-beta.1" +# regex for ignoring tags +ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +# limit the number of commits included in the changelog. +# limit_commits = 42 diff --git a/core/Cargo.toml b/core/Cargo.toml index c0fc911..923995c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -3,7 +3,7 @@ name = "leptos_form_core" version.workspace = true edition.workspace = true authors.workspace = true -rust-version = "1.75.0" +repository.workspace = true [dependencies] derivative.workspace = true diff --git a/leptos_form/Cargo.toml b/leptos_form/Cargo.toml index fcbc0ad..eafd087 100644 --- a/leptos_form/Cargo.toml +++ b/leptos_form/Cargo.toml @@ -3,11 +3,12 @@ name = "leptos_form" version.workspace = true edition.workspace = true authors.workspace = true +repository.workspace = true [dependencies] leptos.workspace = true -leptos_form_core.path = "../core" -leptos_form_proc_macros.path = "../proc_macros" +leptos_form_core.workspace = true +leptos_form_proc_macros.workspace = true leptos_router.workspace = true wasm-bindgen.workspace = true diff --git a/leptos_form/Crate.md b/leptos_form/Crate.md deleted file mode 100644 index e5f47eb..0000000 --- a/leptos_form/Crate.md +++ /dev/null @@ -1,89 +0,0 @@ -# Derive leptos forms from rust structs - -
- - - - - - - - - - - - - - - - - - - -
- -## Documentation - -* [Docs](https://docs.rs/leptos_form) -* [GitHub repository](https://github.com/tlowerison/leptos_form) - -## Features - -* Automatic form parsing -- focus on how your data is represented and not on how to get it in and out of html -* Easy specification of label and input classes, great for Tailwind integration -* Labels are derived from struct fields, and can be set to a form-wide casing -* DOM layout customization through attributes -* Integration with popular crates - -## Crate features - -This crate offers the following features, all of which are not activated by default: - -- `bigdecimal`: Provides impls for [`BigDecimal`](https://docs.rs/bigdecimal/latest/bigdecimal/struct.BigDecimal.html) -- `chrono`: Provides impls for [`DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html), [`NaiveDate`](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDate.html), [`NaiveDateTime`](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDateTime.html) -- `num-bigint`: Provides impls for [`BigInt`](https://docs.rs/num-bigint/latest/num_bigint/struct.BigInt.html) and [`BigUint`](https://docs.rs/num-bigint/latest/num_bigint/struct.BigUint.html) -- `uuid`: Provides impls for [`Uuid`](https://docs.rs/uuid/latest/uuid/struct.Uuid.html) - -## Example - -```rust -mod my_crate { - use leptos::*; - use leptos_form::prelude::*; - use serde::*; - - #[derive(Clone, Debug, Default, Deserialize, Form, Serialize)] - #[form( - component( - action = create_my_data(my_data), - submit = view!(), - on_success = |db_my_data, _| view!(
{format!("Created {}", db_my_data.id)}
), - reset_on_success, - ), - label(wrap(class = "my-class", rename_all = "Title Case")), - )] - pub struct MyData { - pub my_name: String, - } - - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct DbMyData { - pub id: i32, - pub name: String, - } - - #[component] - pub fn MyComponent() -> impl IntoView { - view!() - } - - #[server] - async fn create_my_data(my_data: MyData) -> Result { - todo!() - } -} -``` diff --git a/leptos_form/Crate.md b/leptos_form/Crate.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/leptos_form/Crate.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/proc_macros/Cargo.toml b/proc_macros/Cargo.toml index bfff519..53105b4 100644 --- a/proc_macros/Cargo.toml +++ b/proc_macros/Cargo.toml @@ -3,9 +3,10 @@ name = "leptos_form_proc_macros" version.workspace = true authors.workspace = true edition.workspace = true +repository.workspace = true [dependencies] -leptos_form_proc_macros_core.path = "./core" +leptos_form_proc_macros_core.workspace = true [lib] proc-macro = true diff --git a/proc_macros/core/Cargo.toml b/proc_macros/core/Cargo.toml index 4050a08..000688d 100644 --- a/proc_macros/core/Cargo.toml +++ b/proc_macros/core/Cargo.toml @@ -3,6 +3,7 @@ name = "leptos_form_proc_macros_core" version.workspace = true edition.workspace = true authors.workspace = true +repository.workspace = true [dependencies] convert_case.workspace = true diff --git a/release-plz.toml b/release-plz.toml new file mode 100644 index 0000000..a411f82 --- /dev/null +++ b/release-plz.toml @@ -0,0 +1,27 @@ +[workspace] +# path of the git-cliff configuration +changelog_config = "cliff.toml" + +# enable changelog updates +changelog_update = true + +# update dependencies with `cargo update` +dependencies_update = true + +# create tags for the releases +git_tag_enable = true + +# disable GitHub releases +git_release_enable = false + +# labels for the release PR +pr_labels = ["release"] + +# disallow updating repositories with uncommitted changes +allow_dirty = false + +# disallow packaging with uncommitted changes +publish_allow_dirty = false + +# disable running `cargo-semver-checks` +semver_check = false