Skip to content

Commit 142233a

Browse files
committed
feat: Rework the configuration system
This refactors most parts of the configuration system. Splitting it up into a command line argument model, a persistent config file model, and the runtime model. The command line arguments (including env-vars) will override the persisted (or default) config model. It also adds the ability to parse YAML, JSON, and cargo metadata in addition to the TOML variant. This prepares the configuration for future enhancements, like build profiles, ...
1 parent 033c760 commit 142233a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3267
-1141
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ jobs:
138138

139139
test-examples:
140140
needs: test # Ensure test is run first.
141-
env:
142-
# for the CI we need to disable those checks, as we may run with a pre-release version, which would force us to
143-
# replace all version requirements with pre-release requirements for this version.
144-
TRUNK_REQUIRED_VERSION: '*'
145141
strategy:
146142
fail-fast: false
147143
max-parallel: 32
@@ -200,7 +196,12 @@ jobs:
200196

201197
- name: Build | Examples | ${{ matrix.example }} on ${{ matrix.os }}
202198
shell: bash
203-
run: $GITHUB_WORKSPACE/trunk --config=examples/${{ matrix.example }}/Trunk.toml build
199+
env:
200+
# for the CI we need to disable those checks, as we may run with a pre-release version, which would force us to
201+
# replace all version requirements with pre-release requirements for this version.
202+
TRUNK_REQUIRED_VERSION: '*'
203+
run: |
204+
$GITHUB_WORKSPACE/trunk --config=examples/${{ matrix.example }} build
204205
205206
examples:
206207
runs-on: ubuntu-22.04
@@ -214,3 +215,31 @@ jobs:
214215
- name: Failure
215216
if: ${{ contains(needs.*.result, 'failure') }}
216217
run: exit 1
218+
219+
uncommitted:
220+
runs-on: ubuntu-22.04
221+
needs:
222+
- test
223+
steps:
224+
- name: Setup | Checkout
225+
uses: actions/checkout@v4
226+
227+
- name: Setup | Download CLI
228+
uses: actions/download-artifact@v4
229+
with:
230+
name: test-cli-ubuntu-latest
231+
232+
- name: Setup | Make executable
233+
run: chmod a+x $GITHUB_WORKSPACE/trunk
234+
235+
- name: Generate | Config Schema
236+
run: |
237+
$GITHUB_WORKSPACE/trunk config generate-schema schemas/config.json
238+
239+
- name: Diff | Config Schema
240+
run: |
241+
git diff --quiet schemas/config.json
242+
if [ $? -gt 0 ]; then
243+
echo "::error::Uncommitted changes for schemas/config.json (run `cargo run -- config generate-schema schemas/config.json` after making changes to the configuration model)"
244+
exit 1
245+
fi

Cargo.lock

Lines changed: 63 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "trunk"
3-
version = "0.20.0"
3+
version = "0.21.0-alpha.1"
44
edition = "2021"
55
description = "Build, bundle & ship your Rust WASM application to the web."
66
license = "MIT/Apache-2.0"
@@ -54,10 +54,12 @@ parking_lot = "0.12"
5454
remove_dir_all = "0.8"
5555
reqwest = { version = "0.12", default-features = false, features = ["stream", "trust-dns"] }
5656
sha2 = "0.10"
57+
schemars = { version = "0.8", features = ["derive"] }
5758
seahash = { version = "4", features = ["use_std"] }
5859
semver = "1"
5960
serde = { version = "1", features = ["derive"] }
6061
serde_json = "1"
62+
serde_yaml = "=0.9.33" # serde-yaml is deprecated, but "just works", let's see who becomes the next serde_yaml
6163
strum = { version = "0.26", features = ["derive"] }
6264
tar = "0.4"
6365
time = { version = "0.3", features = ["serde-well-known"] }

examples/cargo-manifest/Cargo.lock

Lines changed: 154 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cargo-manifest/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "cargo-manifest-example"
3+
version = "0.1.0"
4+
authors = ["Jens Reimann <ctron@dentrassi.de>"]
5+
edition = "2021"
6+
7+
[dependencies]
8+
console_error_panic_hook = "0.1"
9+
wasm-bindgen = "0.2"
10+
web-sys = { version = "0.3", features = [
11+
"console",
12+
"Document",
13+
"HtmlElement",
14+
"Node",
15+
"Text",
16+
"Window",
17+
] }
18+
19+
[package.metadata.trunk.build]
20+
target = "index.html"
21+
dist = "dist"
22+
23+
[package.metadata.trunk.serve]
24+
port = 9090

examples/cargo-manifest/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Trunk | cargo-manifest
2+
=========================
3+
An example application demonstrating building a vanilla Rust (no frameworks) WASM web application having the
4+
configuration in the `Cargo.toml` file instead.
5+
6+
Once you've installed Trunk, simply execute `trunk serve --open` from this example's directory, and you should see the
7+
web application rendered in your browser.
8+

0 commit comments

Comments
 (0)