allframe 0.1.3

The Composable Rust API Framework - TDD-first, compile-time DI, CQRS, protocol-agnostic
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# AllFrame - cargo-make task configuration
# Install: cargo install cargo-make
# Usage: cargo make <task>

[config]
default_to_workspace = false
min_version = "0.36.0"
# Always run from workspace root
main_project_member = "."

[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_WORKSPACE_MAKEFILE = true
RUST_BACKTRACE = 0

# Default task - show help
[tasks.default]
alias = "help"

# Help - List all available tasks
[tasks.help]
description = "Show available tasks"
script = '''
echo "AllFrame Development Tasks"
echo ""
echo "Quality Gates:"
echo "  cargo make lint          - Check formatting and run clippy (CI mode)"
echo "  cargo make lint-check    - Check code formatting without modifying files"
echo "  cargo make lint-sort     - Check if Cargo.toml dependencies are sorted"
echo "  cargo make format        - Format all Rust code"
echo "  cargo make format-sort   - Sort Cargo.toml dependencies"
echo ""
echo "Testing:"
echo "  cargo make test          - Run all tests with main features"
echo "  cargo make test-all      - Run all tests with all features"
echo "  cargo make test-minimal  - Run tests with no features"
echo ""
echo "Building:"
echo "  cargo make build         - Build in debug mode"
echo "  cargo make build-release - Build in release mode"
echo "  cargo make clean         - Clean build artifacts"
echo ""
echo "Tools:"
echo "  cargo make install-tools - Install required development tools"
echo ""
echo "CI/CD:"
echo "  cargo make ci            - Run all CI checks (lint + test + build)"
echo ""
echo "Publishing:"
echo "  cargo make version-check   - Check which crates need publishing"
echo "  cargo make version-bump    - Bump version (patch by default)"
echo "  cargo make publish-dry-run - Verify all crates are ready to publish"
echo "  cargo make publish-all     - Publish all crates (parallel, skips published)"
'''

# Quality Gates

[tasks.lint-check]
description = "Check code formatting without modifying files"
cwd = "crates/allframe-core"
command = "cargo"
args = ["fmt", "--check"]

[tasks.lint-clippy]
description = "Run clippy with warnings as errors"
cwd = "crates/allframe-core"
command = "cargo"
args = ["clippy", "--features", "di,openapi,router,cqrs,otel", "--", "-D", "warnings"]

[tasks.lint]
description = "Run both format check and clippy (CI mode)"
dependencies = ["lint-check", "lint-clippy"]

[tasks.lint-sort]
description = "Check if Cargo.toml dependencies are sorted"
cwd = "crates/allframe-core"
command = "cargo"
args = ["sort", "--check"]

[tasks.format]
description = "Format all Rust code"
cwd = "crates/allframe-core"
command = "cargo"
args = ["fmt"]

[tasks.format-sort]
description = "Sort Cargo.toml dependencies"
cwd = "crates/allframe-core"
command = "cargo"
args = ["sort", "-w"]

# Testing

[tasks.test]
description = "Run tests with main features"
cwd = "crates/allframe-core"
command = "cargo"
args = ["test", "--features", "di,openapi,router,cqrs"]

[tasks.test-all]
description = "Run tests with all features (excluding allsource)"
cwd = "crates/allframe-core"
command = "cargo"
args = ["test", "--features", "di,openapi,router,cqrs,otel"]

[tasks.test-minimal]
description = "Run tests with no features"
cwd = "crates/allframe-core"
command = "cargo"
args = ["test", "--no-default-features"]

# Building

[tasks.build]
description = "Build in debug mode"
cwd = "crates/allframe-core"
command = "cargo"
args = ["build"]

[tasks.build-release]
description = "Build in release mode"
cwd = "crates/allframe-core"
command = "cargo"
args = ["build", "--release"]

[tasks.clean]
description = "Clean build artifacts"
cwd = "crates/allframe-core"
command = "cargo"
args = ["clean"]

# Tools

[tasks.install-tools]
description = "Install required development tools"
script = '''
echo "Installing development tools..."
cargo install cargo-sort --quiet || true
cargo install cargo-bloat --quiet || true
cargo install cargo-make --quiet || true
echo "✅ Tools installed!"
'''

# CI/CD

[tasks.ci]
description = "Run all CI checks"
dependencies = ["lint", "lint-sort", "test", "build"]
script = '''
echo ""
echo "✅ All CI checks passed!"
'''

# Size monitoring

[tasks.size-minimal]
description = "Measure minimal binary size"
cwd = "crates/allframe-core"
command = "cargo"
args = ["bloat", "--release", "--example", "minimal", "--no-default-features", "--crates"]

[tasks.size-default]
description = "Measure default features binary size"
cwd = "crates/allframe-core"
command = "cargo"
args = ["bloat", "--release", "--example", "default_features", "--features", "di,openapi,router", "--crates"]

[tasks.size-all]
description = "Measure all features binary size"
cwd = "crates/allframe-core"
command = "cargo"
args = ["bloat", "--release", "--example", "all_features", "--features", "di,openapi,router,cqrs,otel", "--crates"]

[tasks.size]
description = "Measure binary sizes for all configurations"
dependencies = ["size-minimal", "size-default", "size-all"]

# Binary size monitoring tasks

[tasks.check-size]
description = "Check binary sizes against limits"
script = '''\n#!/usr/bin/env bash
./scripts/check_size.sh
'''

[tasks.analyze-size]
description = "Analyze binary sizes in detail"
script = '''\n#!/usr/bin/env bash
./scripts/analyze_size.sh full
'''

[tasks.analyze-size-minimal]
description = "Analyze minimal binary size"
script = '''\n#!/usr/bin/env bash
./scripts/analyze_size.sh minimal
'''

[tasks.analyze-size-default]
description = "Analyze default binary size"
script = '''\n#!/usr/bin/env bash
./scripts/analyze_size.sh default
'''

[tasks.analyze-size-main]
description = "Analyze main features binary size"
script = '''\n#!/usr/bin/env bash
./scripts/analyze_size.sh all
'''

# Publishing to crates.io
# Dependency graph:
#   allframe-macros (no deps)     ─┬─► allframe-core ─► allframe-mcp
#   allframe-forge (no deps)      ─┘

[tasks.version-bump]
description = "Bump workspace version (patch, minor, or major)"
workspace = false
script_runner = "@shell"
script = '''
#!/usr/bin/env bash
set -e

# Navigate to workspace root
cd "$(git rev-parse --show-toplevel)"

BUMP_TYPE=${1:-patch}
CARGO_TOML="Cargo.toml"

# Get current workspace.package version
CURRENT=$(sed -n '/\[workspace\.package\]/,/\[/p' "$CARGO_TOML" | grep '^version' | cut -d'"' -f2)
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"

case "$BUMP_TYPE" in
    major)
        MAJOR=$((MAJOR + 1))
        MINOR=0
        PATCH=0
        ;;
    minor)
        MINOR=$((MINOR + 1))
        PATCH=0
        ;;
    patch)
        PATCH=$((PATCH + 1))
        ;;
    *)
        echo "Usage: cargo make version-bump [patch|minor|major]"
        exit 1
        ;;
esac

NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "Bumping version: ${CURRENT} → ${NEW_VERSION}"

# Update workspace.package version (in [workspace.package] section only)
sed -i '' "/\[workspace\.package\]/,/\[.*\]/{s/^version = \"${CURRENT}\"/version = \"${NEW_VERSION}\"/;}" "$CARGO_TOML"

# Update allframe-mcp dependency on allframe-core
sed -i '' "s/allframe-core = { version = \"${CURRENT}\"/allframe-core = { version = \"${NEW_VERSION}\"/" crates/allframe-mcp/Cargo.toml

echo "✅ Version bumped to ${NEW_VERSION}"
echo ""
echo "Updated files:"
echo "  - Cargo.toml (workspace.package.version)"
echo "  - crates/allframe-mcp/Cargo.toml (allframe-core dependency)"
'''

[tasks.version-check]
description = "Check which crates need publishing"
workspace = false
script_runner = "@shell"
script = '''
#!/usr/bin/env bash

# Navigate to workspace root
cd "$(git rev-parse --show-toplevel)"

# Get workspace.package version (after [workspace.package] section)
LOCAL_VERSION=$(sed -n '/\[workspace\.package\]/,/\[/p' Cargo.toml | grep '^version' | cut -d'"' -f2)
echo "Workspace version: ${LOCAL_VERSION}"
echo ""

check_crate() {
    local crate=$1
    local published=$(curl -s "https://crates.io/api/v1/crates/${crate}" | grep -o "\"${LOCAL_VERSION}\"" | head -1)
    if [ -n "$published" ]; then
        echo "  ✅ ${crate}@${LOCAL_VERSION} - already published"
    else
        echo "  📦 ${crate}@${LOCAL_VERSION} - needs publishing"
    fi
}

echo "Crate status:"
check_crate "allframe-macros"
check_crate "allframe-core"
check_crate "allframe-mcp"
check_crate "allframe-forge"
'''

[tasks.publish-macros]
description = "Publish allframe-macros to crates.io"
cwd = "crates/allframe-macros"
command = "cargo"
args = ["publish"]

[tasks.publish-core]
description = "Publish allframe-core to crates.io"
cwd = "crates/allframe-core"
command = "cargo"
args = ["publish"]

[tasks.publish-mcp]
description = "Publish allframe-mcp to crates.io"
cwd = "crates/allframe-mcp"
command = "cargo"
args = ["publish"]

[tasks.publish-forge]
description = "Publish allframe-forge to crates.io"
cwd = "crates/allframe-forge"
command = "cargo"
args = ["publish"]

[tasks.publish-wait]
description = "Wait for crates.io indexing"
script = '''
echo "⏳ Waiting 30s for crates.io indexing..."
sleep 30
echo "✅ Done waiting"
'''

[tasks.publish-all]
description = "Publish all crates to crates.io in dependency order (parallel where possible)"
workspace = false
script_runner = "@shell"
script = '''
#!/usr/bin/env bash
set -e

# Navigate to workspace root
cd "$(git rev-parse --show-toplevel)"

# Get workspace.package version
LOCAL_VERSION=$(sed -n '/\[workspace\.package\]/,/\[/p' Cargo.toml | grep '^version' | cut -d'"' -f2)
echo "🚀 Publishing AllFrame crates v${LOCAL_VERSION} to crates.io"
echo ""

# Function to check if version is already published
is_published() {
    local crate=$1
    local version=$2
    # Check crates.io API
    local published=$(curl -s "https://crates.io/api/v1/crates/${crate}" | grep -o "\"${version}\"" | head -1)
    [ -n "$published" ]
}

# Function to publish a crate if not already published
publish_crate() {
    local crate=$1
    local path=$2

    if is_published "$crate" "$LOCAL_VERSION"; then
        echo "⏭️  ${crate}@${LOCAL_VERSION} already published, skipping"
        return 0
    fi

    echo "📦 Publishing ${crate}@${LOCAL_VERSION}..."
    cd "$path" && cargo publish --allow-dirty && cd - > /dev/null
    echo "✅ ${crate}@${LOCAL_VERSION} published"
}

# Wave 1: No internal dependencies (parallel)
echo "━━━ Wave 1: Independent crates (parallel) ━━━"
publish_crate "allframe-macros" "crates/allframe-macros" &
PID_MACROS=$!
publish_crate "allframe-forge" "crates/allframe-forge" &
PID_FORGE=$!

# Wait for wave 1
wait $PID_MACROS
MACROS_EXIT=$?
wait $PID_FORGE

if [ $MACROS_EXIT -ne 0 ]; then
    echo "❌ Failed to publish allframe-macros"
    exit 1
fi

# Brief wait for crates.io indexing
echo "⏳ Waiting 15s for crates.io indexing..."
sleep 15

# Wave 2: Depends on macros
echo ""
echo "━━━ Wave 2: allframe-core (depends on macros) ━━━"
publish_crate "allframe-core" "crates/allframe-core"

# Brief wait for crates.io indexing
echo "⏳ Waiting 15s for crates.io indexing..."
sleep 15

# Wave 3: Depends on core
echo ""
echo "━━━ Wave 3: allframe-mcp (depends on core) ━━━"
publish_crate "allframe-mcp" "crates/allframe-mcp"

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ All crates published successfully!"
echo ""
echo "  allframe-macros  @ ${LOCAL_VERSION}"
echo "  allframe-core    @ ${LOCAL_VERSION}"
echo "  allframe-mcp     @ ${LOCAL_VERSION}"
echo "  allframe-forge   @ ${LOCAL_VERSION}"
echo ""
echo "View at: https://crates.io/crates/allframe-core"
'''

[tasks.publish-dry-run]
description = "Dry-run publish all crates (no actual publish)"
script = '''
#!/usr/bin/env bash
set -e

echo "🔍 Dry-run publish for AllFrame crates"
echo ""

echo "📦 [1/4] Checking allframe-macros..."
cd crates/allframe-macros && cargo publish --dry-run && cd ../..

echo "📦 [2/4] Checking allframe-core..."
cd crates/allframe-core && cargo publish --dry-run && cd ../..

echo "📦 [3/4] Checking allframe-mcp..."
cd crates/allframe-mcp && cargo publish --dry-run && cd ../..

echo "📦 [4/4] Checking allframe-forge..."
cd crates/allframe-forge && cargo publish --dry-run && cd ../..

echo ""
echo "✅ All crates ready for publishing!"
'''