mirror of
https://github.com/chatmail/core.git
synced 2026-09-22 13:01:21 +03:00
feat: generate jsonrpc headers at build time (#8350)
Discussion in https://github.com/chatmail/yerpc/issues/77. The necessary yerpc changes for this PR are in https://github.com/chatmail/yerpc/pull/78 This is also a preparation for #8330
This commit is contained in:
@@ -31,15 +31,15 @@ jobs:
|
|||||||
package-manager-cache: false # never use caching in release builds
|
package-manager-cache: false # never use caching in release builds
|
||||||
|
|
||||||
- name: Install dependencies without running scripts
|
- name: Install dependencies without running scripts
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: npm install --ignore-scripts
|
run: npm install --ignore-scripts
|
||||||
|
|
||||||
- name: Package
|
- name: Package
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: |
|
run: |
|
||||||
npm run build
|
npm run build
|
||||||
npm pack .
|
npm pack .
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: npm publish --provenance deltachat-jsonrpc-client-* --access public
|
run: npm publish --provenance deltachat-jsonrpc-client-* --access public
|
||||||
|
|||||||
8
.github/workflows/jsonrpc.yml
vendored
8
.github/workflows/jsonrpc.yml
vendored
@@ -30,16 +30,16 @@ jobs:
|
|||||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
cache-bin: false
|
cache-bin: false
|
||||||
- name: npm install
|
- name: npm install
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Build TypeScript, run Rust tests, generate bindings
|
- name: Build TypeScript, run Rust tests, generate bindings
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: npm run build
|
run: npm run build
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: npm run test
|
run: npm run test
|
||||||
env:
|
env:
|
||||||
CHATMAIL_DOMAIN: ${{ vars.CHATMAIL_DOMAIN }}
|
CHATMAIL_DOMAIN: ${{ vars.CHATMAIL_DOMAIN }}
|
||||||
- name: Run linter
|
- name: Run linter
|
||||||
working-directory: deltachat-jsonrpc/typescript
|
working-directory: deltachat-jsonrpc-bindings/typescript
|
||||||
run: npm run prettier:check
|
run: npm run prettier:check
|
||||||
|
|||||||
4
.github/workflows/upload-docs.yml
vendored
4
.github/workflows/upload-docs.yml
vendored
@@ -81,7 +81,7 @@ jobs:
|
|||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ./deltachat-jsonrpc/typescript
|
working-directory: ./deltachat-jsonrpc-bindings/typescript
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
@@ -104,7 +104,7 @@ jobs:
|
|||||||
mkdir -p "$HOME/.ssh"
|
mkdir -p "$HOME/.ssh"
|
||||||
echo "${{ secrets.JS_JSONRPC_DOCS_SSH_KEY }}" > "$HOME/.ssh/key"
|
echo "${{ secrets.JS_JSONRPC_DOCS_SSH_KEY }}" > "$HOME/.ssh/key"
|
||||||
chmod 600 "$HOME/.ssh/key"
|
chmod 600 "$HOME/.ssh/key"
|
||||||
rsync -avzh --delete -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/deltachat-jsonrpc/typescript/docs/ "${{ secrets.JS_JSONRPC_DOCS_SSH_USER }}@js.jsonrpc.delta.chat:"
|
rsync -avzh --delete -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/deltachat-jsonrpc-bindings/typescript/docs/ "${{ secrets.JS_JSONRPC_DOCS_SSH_USER }}@js.jsonrpc.delta.chat:"
|
||||||
|
|
||||||
build-cffi:
|
build-cffi:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
15
Cargo.lock
generated
15
Cargo.lock
generated
@@ -1454,6 +1454,13 @@ dependencies = [
|
|||||||
"yerpc",
|
"yerpc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deltachat-jsonrpc-bindings"
|
||||||
|
version = "2.60.0-dev"
|
||||||
|
dependencies = [
|
||||||
|
"deltachat-jsonrpc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deltachat-repl"
|
name = "deltachat-repl"
|
||||||
version = "2.60.0-dev"
|
version = "2.60.0-dev"
|
||||||
@@ -7528,9 +7535,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yerpc"
|
name = "yerpc"
|
||||||
version = "0.6.4"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1dc24983fbe850227bfc1de89bf8cbfb3e2463afc322e0de2f155c4c23d06445"
|
checksum = "6924db1f1011f1d22566c45c7090aa66c3107c3c463ca32beaa8b2327127040a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-channel 1.9.0",
|
"async-channel 1.9.0",
|
||||||
@@ -7548,9 +7555,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yerpc_derive"
|
name = "yerpc_derive"
|
||||||
version = "0.6.3"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4d8560d021437420316370db865e44c000bf86380b47cf05e49be9d652042bf5"
|
checksum = "42c374248c189b15a7f0660db3984e9dcc790ec15f4b44e932e92be49de829f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"convert_case",
|
"convert_case",
|
||||||
"darling",
|
"darling",
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ members = [
|
|||||||
"deltachat-ffi",
|
"deltachat-ffi",
|
||||||
"deltachat_derive",
|
"deltachat_derive",
|
||||||
"deltachat-jsonrpc",
|
"deltachat-jsonrpc",
|
||||||
|
"deltachat-jsonrpc-bindings",
|
||||||
"deltachat-rpc-server",
|
"deltachat-rpc-server",
|
||||||
"deltachat-ratelimit",
|
"deltachat-ratelimit",
|
||||||
"deltachat-repl",
|
"deltachat-repl",
|
||||||
@@ -183,6 +184,7 @@ base64 = "0.22"
|
|||||||
chrono = { version = "0.4.44", default-features = false }
|
chrono = { version = "0.4.44", default-features = false }
|
||||||
deltachat-contact-tools = { path = "deltachat-contact-tools" }
|
deltachat-contact-tools = { path = "deltachat-contact-tools" }
|
||||||
deltachat-jsonrpc = { path = "deltachat-jsonrpc", default-features = false }
|
deltachat-jsonrpc = { path = "deltachat-jsonrpc", default-features = false }
|
||||||
|
deltachat-jsonrpc-bindings = { path = "deltachat-jsonrpc-bindings", default-features = false }
|
||||||
deltachat = { path = ".", default-features = false }
|
deltachat = { path = ".", default-features = false }
|
||||||
futures = "0.3.32"
|
futures = "0.3.32"
|
||||||
futures-lite = "2.6.1"
|
futures-lite = "2.6.1"
|
||||||
@@ -202,7 +204,7 @@ thiserror = "2"
|
|||||||
tokio = "1"
|
tokio = "1"
|
||||||
tokio-util = "0.7.18"
|
tokio-util = "0.7.18"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
yerpc = "0.6.4"
|
yerpc = "0.7"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["vendored"]
|
default = ["vendored"]
|
||||||
|
|||||||
16
deltachat-jsonrpc-bindings/Cargo.toml
Normal file
16
deltachat-jsonrpc-bindings/Cargo.toml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "deltachat-jsonrpc-bindings"
|
||||||
|
version = "2.60.0-dev"
|
||||||
|
description = "Autogenerate DeltaChat JSON-RPC API bindings at build time"
|
||||||
|
edition = "2024"
|
||||||
|
license = "MPL-2.0"
|
||||||
|
repository = "https://github.com/chatmail/core"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
deltachat-jsonrpc = { workspace = true }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["vendored"]
|
||||||
|
vendored = ["deltachat-jsonrpc/vendored"]
|
||||||
6
deltachat-jsonrpc-bindings/build.rs
Normal file
6
deltachat-jsonrpc-bindings/build.rs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
use deltachat_jsonrpc::api::write_ts_bindings;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
write_ts_bindings(Path::new("typescript/generated"));
|
||||||
|
}
|
||||||
1
deltachat-jsonrpc-bindings/src/lib.rs
Normal file
1
deltachat-jsonrpc-bindings/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -153,7 +153,7 @@ impl CommandApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rpc(all_positional, ts_outdir = "typescript/generated")]
|
#[rpc(all_positional)]
|
||||||
impl CommandApi {
|
impl CommandApi {
|
||||||
/// Test function.
|
/// Test function.
|
||||||
async fn sleep(&self, delay: f64) {
|
async fn sleep(&self, delay: f64) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ for (const { folder_name, package_name } of platform_package_names) {
|
|||||||
|
|
||||||
if (is_local) {
|
if (is_local) {
|
||||||
package_json.peerDependencies["@deltachat/jsonrpc-client"] =
|
package_json.peerDependencies["@deltachat/jsonrpc-client"] =
|
||||||
`file:${join(expected_cwd, "/../../deltachat-jsonrpc/typescript")}`;
|
`file:${join(expected_cwd, "/../../deltachat-jsonrpc-bindings/typescript")}`;
|
||||||
} else {
|
} else {
|
||||||
package_json.peerDependencies["@deltachat/jsonrpc-client"] = "*";
|
package_json.peerDependencies["@deltachat/jsonrpc-client"] = "*";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
./deltachat-contact-tools
|
./deltachat-contact-tools
|
||||||
./deltachat-ffi
|
./deltachat-ffi
|
||||||
./deltachat-jsonrpc
|
./deltachat-jsonrpc
|
||||||
|
./deltachat-jsonrpc-bindings
|
||||||
./deltachat-ratelimit
|
./deltachat-ratelimit
|
||||||
./deltachat-repl
|
./deltachat-repl
|
||||||
./deltachat-rpc-client
|
./deltachat-rpc-client
|
||||||
|
|||||||
@@ -67,13 +67,14 @@ def main():
|
|||||||
parser.add_argument("newversion")
|
parser.add_argument("newversion")
|
||||||
|
|
||||||
json_list = [
|
json_list = [
|
||||||
"deltachat-jsonrpc/typescript/package.json",
|
"deltachat-jsonrpc-bindings/typescript/package.json",
|
||||||
"deltachat-rpc-server/npm-package/package.json",
|
"deltachat-rpc-server/npm-package/package.json",
|
||||||
]
|
]
|
||||||
toml_list = [
|
toml_list = [
|
||||||
"Cargo.toml",
|
"Cargo.toml",
|
||||||
"deltachat-ffi/Cargo.toml",
|
"deltachat-ffi/Cargo.toml",
|
||||||
"deltachat-jsonrpc/Cargo.toml",
|
"deltachat-jsonrpc/Cargo.toml",
|
||||||
|
"deltachat-jsonrpc-bindings/Cargo.toml",
|
||||||
"deltachat-rpc-server/Cargo.toml",
|
"deltachat-rpc-server/Cargo.toml",
|
||||||
"deltachat-repl/Cargo.toml",
|
"deltachat-repl/Cargo.toml",
|
||||||
"python/pyproject.toml",
|
"python/pyproject.toml",
|
||||||
|
|||||||
Reference in New Issue
Block a user