Skip to content

Commit

Permalink
Feature: rust client generation (initial implementation) (#56)
Browse files Browse the repository at this point in the history
* setup rust project

* rename crate

* blah

* additional experiments

* messing with rust client

* clean up dependencies

* blah

* starting to create a rust client reference

* further progress on rust-client-reference

* test rust client finished minus streaming

* sse experiments

* alsdkfjsa

* blarg

* further rust progress

* further rust progress

* rust client progress

* get rust formatting to work

* further codegen progress

* asdf

* further rust progress

* get all basic type generation finished

* further progress

* fixing hashmap issues

* asdf

* further progress

* start working on records

* further record progress

* start rust recursive support

* recursive object example

* rust recursive type progress

* pub get

* ref fixes and other codegen fixes

* recursive discriminator reference

* finish initial recursive implementation

* fix recursion issues

* blah

* rename arri request error to arri error

* fix test issues

* setting up rust service generation

* fix generation step

* asdfas

* move to new folder structure

* cargo build

* rewrite rust codegen reference

* further rust progress

* finished ObjectWithOptionalFields (tests failing)

* fix failed test

* remove unneeded imports

* progress

* lint rules + start over on rust codegen

* start working out rust stuff

* start adding templates for recursive types

* setup reference for recursive objects

* asdf

* add f64 and i8 to generation

* start working on object generation

* further rust progress (enums, and arrays)

* set up refs

* fix build err

* blah

* prefix arri commands with pnpm

* another attempt

* make tests not run on drafts

* remove serve

* move parenthesis to correct place

* fix import

* asdf

* fix build errors

* remove rust-codegen

* fix toJson output issue

* update

* getting output to better match example_client.rs

* start working out discriminator generation

* further progress on discriminator

* get type generation working

* start setting up functions

* start setting up see stuff

* get http rpcs working

* finish codegen for http rpcs

* cleanup codegen output

* finish rust simple http implementation

* setup github actions for rust

* add rust to version sync script

* remove extra keywords

* add rust client to publish-all script
add readme to rust client.

* remove @nx/eslint reference

* fix linting error

* add "setup gradle step"
  • Loading branch information
joshmossas authored Jun 18, 2024
1 parent 6f6ab69 commit a18121a
Show file tree
Hide file tree
Showing 60 changed files with 16,661 additions and 46 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ jobs:
fetch-depth: 0
- name: Install Dart
uses: dart-lang/setup-dart@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
Expand Down Expand Up @@ -78,6 +82,10 @@ jobs:
fetch-depth: 0
- name: Install Dart
uses: dart-lang/setup-dart@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dist
tmp
/out-tsc
**/.output
**/target

# dependencies
node_modules
Expand Down
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"mathiasfrohlich.kotlin",
"dart-code.dart-code",
"dart-code.flutter",
"dart-code.dart-code"
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"Arri",
"arrirpc",
"autoroutes",
"chrono",
"citty",
"codegen",
"Consola",
Expand All @@ -32,6 +33,7 @@
"nitropack",
"ofetch",
"pathe",
"reqwest",
"postversion",
"pubspec",
"scule",
Expand All @@ -43,6 +45,14 @@
"vals",
"websockets"
],
"rust-analyzer.linkedProjects": [
"languages/rust/rust-client/Cargo.toml",
"languages/rust/rust-codegen-reference/Cargo.toml",
"tests/clients/rust/Cargo.toml"
],
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"eslint.validate": ["json"],
"java.compile.nullAnalysis.mode": "automatic",
"eslint.experimental.useFlatConfig": true
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ignoreFiles = [
"**/**/dist/*.d.ts",
"**/*.dart",
"**/*.kt",
"**/*.rust",
"**/*.rs",
"**/*.zig",
"**/*.swift",
"**/*.go",
Expand Down
3 changes: 3 additions & 0 deletions internal/scripts/publish-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ pnpm publish -r --otp $otp

echo "\n\nPublishing Dart client..."
pnpm nx publish dart-client

echo "\n\nPublishing Rust client..."
pnpm nx publish rust-client
26 changes: 24 additions & 2 deletions internal/scripts/version-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async function main() {
if (!version) {
throw Error("No version in package.json file");
}
// DART packages
const pubspecParts = readFileSync(
"languages/dart/dart-client/pubspec.yaml",
{ encoding: "utf-8" },
Expand All @@ -27,6 +28,7 @@ async function main() {
"languages/dart/dart-client/pubspec.yaml",
pubspecParts.join("\n"),
);
// PACKAGE JSONS
const childPackageJsons = await globby([
"languages/**/package.json",
"tooling/**/package.json",
Expand All @@ -47,9 +49,29 @@ async function main() {
);
});
await Promise.all(tasks);

// sync test clients
execSync("nx run-many -t pub -- get");
execSync("nx run-many -t pub -- get", {
stdio: "inherit",
});

// RUST client
const cargoTomlParts = readFileSync(
"languages/rust/rust-client/cargo.toml",
{ encoding: "utf-8" },
).split("\n");
for (let i = 0; i < cargoTomlParts.length; i++) {
const line = cargoTomlParts[i];
if (line?.startsWith("version = ")) {
cargoTomlParts[i] = `version = "${version}"`;
}
}
writeFileSync(
"languages/rust/rust-client/cargo.toml",
cargoTomlParts.join("\n"),
);
execSync(`nx run-many -t cargo -- check`, {
stdio: "inherit",
});
}

void main();
Loading

0 comments on commit a18121a

Please sign in to comment.