Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.1.1] - 2025-04-23

### 💼 Other

- Alpha release

### 🚜 Refactor

- Make Cargo.toml version easy to bump version

### 📚 Documentation

- Add repository link
- Document features
- Document all features and enable optional features

### ⚙️ Miscellaneous Tasks

- Add check workflow (#1)
- Update cargo manifest files
- Rename macros crate
- Update doc link
- Remove expanded file
- Add release script

<!-- generated by git-cliff -->
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[workspace]
resolver = "3"
members = ["examples/*", "lazybe", "lazybe-macro"]
members = ["examples/*", "lazybe", "lazybe-macros"]

[workspace.package]
version = "0.1.0"
version = "0.1.1" # bump
edition = "2024"
authors = ["Pat Losoponkul <pat.losoponkul@gmail.com>"]
license = "Apache-2.0"
homepage = "https://github.com/patextreme/lazybe"
repository = "https://github.com/patextreme/lazybe"

[workspace.dependencies]
anyhow = "1"
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,16 @@ For a complete working example, see the [minimal API example](./examples/kitchen

# Documentation

The only documentation for now is the [example directory](./examples). There’s no fancy doc site just yet.
- [Example directory](./examples)
- [docs.rs](https://docs.rs/lazybe/latest/lazybe/)

# Releasing

```bash
# Prepare a new version, then merge the PR and create a tag
nix run .#bump

# Publish to crates.io
cargo publish -p lazybe-macros
cargo publish -p lazybe
```
88 changes: 88 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 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]
# template for the 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 | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing s
trim = true
# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
]
# render body even when there are no releases to process
# render_always = true
# output file path
# output = "test.md"

[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 = [
# Replace issue numbers
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit with https://github.com/crate-ci/typos
# If the spelling is incorrect, it will be automatically fixed.
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 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 = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
{ message = ".*", group = "<!-- 10 -->💼 Other" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
tag_pattern = "v[0-9].*"

[bump]
initial_tag = "v0.1.1"
1 change: 1 addition & 0 deletions examples/kitchen-sink/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "example-kitchen-sink"
version.workspace = true
edition.workspace = true
authors.workspace = true
publish = false

[dependencies]
anyhow = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions examples/todo-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "example-todo-postgres"
version.workspace = true
edition.workspace = true
authors.workspace = true
publish = false

[dependencies]
anyhow = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions examples/todo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "example-todo"
version.workspace = true
edition.workspace = true
authors.workspace = true
publish = false

[dependencies]
anyhow = { workspace = true }
Expand Down
39 changes: 39 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,44 @@
};
};

apps = {
bump = {
type = "app";
program =
(pkgs.writeShellApplication {
name = "bump";
runtimeInputs = with pkgs; [
git-cliff
jq
rust
taplo
];
text = ''
NEW_VERSION=$(git-cliff --bump --context | jq -r .[0].version | sed s/^v//)
NEW_VERSION_TAG="v$NEW_VERSION"

echo "Preparing a new version: $NEW_VERSION (tag: $NEW_VERSION_TAG)"
git-cliff --bump -o CHANGELOG.md
sed -i -E "s/^version = .*\# bump$/version = \"$NEW_VERSION\" # bump/" Cargo.toml
sed -i -E "s/^version = .*\# bump$/version = \"$NEW_VERSION\" # bump/" lazybe/Cargo.toml

find . | grep '\.toml$' | xargs -I _ bash -c "echo running taplo on _ && taplo format _"

cargo update lazybe-macros --precise "$NEW_VERSION"
cargo update lazybe --precise "$NEW_VERSION"
git add CHANGELOG.md
git add Cargo.lock
git add Cargo.toml
git add lazybe/Cargo.toml

printf "\nPlease verify if everything is ok, then run the following command ...\n"
echo "> git commit -m \"chore(release): prepare for $NEW_VERSION release\""
'';
}).outPath
+ "/bin/bump";
};
};

devShells.default =
let
rootDir = "$ROOT_DIR";
Expand Down Expand Up @@ -98,6 +136,7 @@
# base
curl
git
git-cliff
hurl
jq
less
Expand Down
7 changes: 6 additions & 1 deletion lazybe-macro/Cargo.toml → lazybe-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[package]
name = "lazybe-macro"
name = "lazybe-macros"
description = "Proc macro for lazybe crate"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
readme = "../README.md"
homepage.workspace = true
repository.workspace = true

[lib]
proc-macro = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 15 additions & 3 deletions lazybe/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
[package]
name = "lazybe"
description = "Derive boring CRUD API boilerplate for Rust backend"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
readme = "../README.md"
homepage.workspace = true
repository.workspace = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
# core
lazybe-macro = { path = "../lazybe-macro" }
tracing = { workspace = true }
sea-query = { workspace = true }
serde = { workspace = true }
Expand All @@ -17,6 +25,10 @@ uuid = { workspace = true, features = ["v4"] }
axum = { workspace = true, optional = true }
utoipa = { workspace = true, optional = true }

[dependencies.lazybe-macros]
path = "../lazybe-macros"
version = "0.1.1" # bump

[dev-dependencies]
anyhow = { workspace = true }
axum = { workspace = true }
Expand All @@ -26,7 +38,7 @@ serde_json = { workspace = true }

[features]
default = []
sqlite = []
postgres = []
sqlite = ["sqlx/sqlite"]
postgres = ["sqlx/postgres"]
axum = ["dep:axum"]
openapi = ["axum", "dep:utoipa"]
2 changes: 2 additions & 0 deletions lazybe/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub trait DbCtx<Db> {

/// Integraion with sqlite database
#[cfg(feature = "sqlite")]
#[doc(cfg(feature = "sqlite"))]
pub mod sqlite {
use sea_query::SqliteQueryBuilder;
use sqlx::Sqlite;
Expand All @@ -35,6 +36,7 @@ pub mod sqlite {

/// Integraion with postgres database
#[cfg(feature = "postgres")]
#[doc(cfg(feature = "postgres"))]
pub mod postgres {
use sea_query::PostgresQueryBuilder;
use sqlx::Postgres;
Expand Down
7 changes: 6 additions & 1 deletion lazybe/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![feature(doc_cfg)]

//! A building block for quickly (and lazily) creating CRUD backend applications.
//!
//! When building a backend application in Rust, you'll often need to expose resources
Expand Down Expand Up @@ -474,19 +476,22 @@ pub mod uuid {

/// Re-exports of proc-macro
pub mod macros {
pub use lazybe_macro::*;
pub use lazybe_macros::*;
}

/// Module implementing [`axum`] router
#[cfg(feature = "axum")]
#[doc(cfg(feature = "axum"))]
pub mod router;

/// Re-exports of [`axum`]
#[cfg(feature = "axum")]
#[doc(cfg(feature = "axum"))]
pub mod axum {
pub use axum::*;
}

/// Utilities for generating a OpenAPI documentation
#[cfg(feature = "openapi")]
#[doc(cfg(feature = "openapi"))]
pub mod openapi;
Loading