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
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

81 changes: 22 additions & 59 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,6 @@ jobs:
cd wasm
cargo clippy -- -D warnings

build-docs-ui:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: npm
cache-dependency-path: docs-ui/package-lock.json
- name: Build and verify syntax highlighting
working-directory: docs-ui
run: |
npm ci
npm test
- name: Check generated highlighter
run: git diff --exit-code -- docs/assets/highlighter.js

publish-library:
needs: build-library
runs-on: ubuntu-latest
Expand All @@ -138,40 +120,45 @@ jobs:
- name: Publish Library to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
RELEASE_REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail

VERSION="${RELEASE_REF_NAME#v}"
CRATES_USER_AGENT="m-bus-parser-release-workflow (https://github.com/maebli/m-bus-parser)"

crate_exists() {
curl -fsS -A "$CRATES_USER_AGENT" "https://crates.io/api/v1/crates/$1/$VERSION" >/dev/null
curl -fsS -A "$CRATES_USER_AGENT" "https://crates.io/api/v1/crates/$1/$2" >/dev/null
}

wait_for_crate() {
crate="$1"
version="$2"
for _ in {1..40}; do
if crate_exists "$crate"; then
if crate_exists "$crate" "$version"; then
return 0
fi
sleep 15
done

echo "$crate $VERSION did not appear on crates.io"
echo "$crate $version did not appear on crates.io"
return 1
}

publish_crate() {
crate="$1"
manifest="$2"
if crate_exists "$crate"; then
echo "$crate $VERSION is already published"
manifest_path="$(realpath "$manifest")"
version="$(
cargo metadata --manifest-path "$manifest" --no-deps --format-version 1 |
jq -r --arg manifest_path "$manifest_path" \
'.packages[] | select(.manifest_path == $manifest_path) | .version'
)"
if crate_exists "$crate" "$version"; then
echo "$crate $version is already published"
return 0
fi

cargo publish --manifest-path "$manifest"
wait_for_crate "$crate"
wait_for_crate "$crate" "$version"
}

publish_crate m-bus-core crates/m-bus-core/Cargo.toml
Expand Down Expand Up @@ -232,7 +219,7 @@ jobs:
cargo publish

publish-wasm:
needs: [build-wasm, build-docs-ui]
needs: build-wasm
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -253,49 +240,25 @@ jobs:
run: |
cd wasm
wasm-pack build --target bundler
- uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false
- name: Install npm dependencies
run: |
cd wasm/pkg
npm install
npm ci
- name: Build and verify docs highlighter
working-directory: docs-ui
run: |
npm ci
npm test
- name: Publish to npm
run: |
cd wasm/pkg
VERSION="$(node -e "const fs=require('fs'); console.log(JSON.parse(fs.readFileSync('package.json','utf8')).version)")"
if npm view "m-bus-parser-wasm-pack@$VERSION" version >/dev/null 2>&1; then
echo "m-bus-parser-wasm-pack $VERSION is already published"
else
npm publish --access public
fi
- name: Publish WASM package
run: wasm-pack publish --access public wasm
- name: Create new artifacts for website
run: |
rm -rf wasm/pkg
cd wasm
wasm-pack build --target web
wasm-pack build --target web --out-dir pkg-web
- name: Copy wasm artifacts to docs
run: |
cp wasm/pkg/m_bus_parser_wasm_pack.js docs/
cp wasm/pkg/m_bus_parser_wasm_pack_bg.wasm docs/
cp wasm/pkg/package.json docs/
if [ -f wasm/pkg/m_bus_parser_wasm_pack_bg.js ]; then
cp wasm/pkg/m_bus_parser_wasm_pack_bg.js docs/
cp wasm/pkg-web/m_bus_parser_wasm_pack.js docs/
cp wasm/pkg-web/m_bus_parser_wasm_pack_bg.wasm docs/
if [ -f wasm/pkg-web/m_bus_parser_wasm_pack_bg.js ]; then
cp wasm/pkg-web/m_bus_parser_wasm_pack_bg.js docs/
fi
- name: Commit updated wasm artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add docs/assets/highlighter.js docs/m_bus_parser_wasm_pack.js docs/m_bus_parser_wasm_pack_bg.js docs/m_bus_parser_wasm_pack_bg.wasm docs/meter.png docs/package.json
git add docs/m_bus_parser_wasm_pack.js docs/m_bus_parser_wasm_pack_bg.js docs/m_bus_parser_wasm_pack_bg.wasm docs/meter.png
git commit -m "Update docs wasm artifacts" || echo "No changes to commit"
git push origin HEAD:main
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ Cargo.lock

# Mac
.DS_Store

# Node build dependencies
node_modules/
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.1]

### Changed

- Replaced the npm-based documentation highlighter with `syntect` running
inside the Rust WebAssembly package. JSON, YAML, CSV, and XML now use
prefixed semantic token classes and an audited high-contrast light/dark
palette.
- CSV renders one row per input frame, with data records represented as
namespaced columns instead of repeating frame metadata for every record.

### Fixed

- Removed doubled source lines that introduced blank gaps in JSON, CSV, and
XML and caused line-number gutters to end halfway through long outputs.
- Restored semantic grouping and the high-contrast eight-color data-record
palette in Mermaid diagrams.

## [0.4.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "m-bus-parser"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
description = "A library for parsing M-Bus frames"
license = "MIT"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ m-bus-parser-cli parse -d "..." -t json
# YAML
m-bus-parser-cli parse -d "..." -t yaml

# CSV
# CSV (one row per input frame; record fields use namespaced columns)
m-bus-parser-cli parse -d "..." -t csv

# Mermaid diagram source (renders in the web app)
# Colored, semantically grouped Mermaid diagram source (renders in the web app)
m-bus-parser-cli parse -d "..." -t mermaid

# Wired-compatible and wireless XML
Expand Down Expand Up @@ -216,8 +216,8 @@ An embedded example (Cortex-M) is in [`examples/cortex-m/`](./examples/cortex-m)
| `table` | default | Width-aware human-readable table |
| `json` | `-t json` | Canonical schema as JSON |
| `yaml` | `-t yaml` | Canonical schema as YAML |
| `csv` | `-t csv` | Stable tidy-record CSV |
| `mermaid` | `-t mermaid` | Layer-oriented Mermaid flowchart |
| `csv` | `-t csv` | One frame row with namespaced record columns |
| `mermaid` | `-t mermaid` | Colored, layer-oriented Mermaid flowchart |
| `xml` | `-t xml` | Wired libmbus-compatible and wireless XML |
| `annotated` | `-t annotated` | Byte-segment annotation envelope |
| `annotated-text`| `-t annotated-text` | Human-readable byte annotations |
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "m-bus-parser-cli"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
description = "A cli to use the library for parsing M-Bus frames"
license = "MIT"
Expand All @@ -22,7 +22,7 @@ default = ["decryption"]
decryption = ["m-bus-parser/decryption"]

[dependencies]
m-bus-parser = { path = "..", version = "0.4.0", features = ["std", "serde"] }
m-bus-parser = { path = "..", version = "0.4.1", features = ["std", "serde"] }
hex = "0.4"
clap = { version = "4.5.4", features = ["derive"] }
terminal_size = "0.4"
Loading
Loading