Skip to content

Commit 61813ac

Browse files
Merge branch 'main' into 96-update-sag-types
2 parents d1e055e + 67045df commit 61813ac

File tree

24 files changed

+1656
-163
lines changed

24 files changed

+1656
-163
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,35 @@ jobs:
5353
- name: Checkout Code
5454
uses: actions/checkout@v5
5555

56+
- name: Install Rust toolchain
57+
uses: dtolnay/rust-toolchain@stable
58+
59+
- name: Cache cargo registry
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
~/.cargo/registry
64+
~/.cargo/git
65+
target
66+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
67+
restore-keys: |
68+
${{ runner.os }}-cargo-
69+
70+
- name: Build project
71+
run: cargo run bundle --path ../definitions --out ../bundles
72+
working-directory: "./cli"
73+
5674
- name: Archive definitions folder
5775
run: |
58-
zip -r definitions.zip definitions
76+
zip -r bundles.zip bundles
5977
6078
- name: Create GitHub Release
6179
uses: softprops/action-gh-release@v2
6280
with:
6381
tag_name: ${{ github.ref_name }}
6482
name: Release ${{ github.ref_name }}
6583
files: |
66-
definitions.zip
84+
bundles.zip
6785
generate_release_notes: true
6886
make_latest: true
6987
env:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
**/node_modules
44
.idea
55
reader/ts/src/*.js
6-
reader/ts/build
6+
reader/ts/build
7+
bundles
8+
reader/**/*.js

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ tokio = "1.47.0"
1919
futures = "0.3.31"
2020
zip = "6.0.0"
2121
bytes = "1.10.1"
22-
code0-definition-reader= "0.0.12"
22+
prost = "0.14.1"
23+
code0-definition-reader= "0.0.13"

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] }
2222
futures = { workspace = true }
2323
zip = { workspace = true }
2424
bytes = { workspace = true }
25+
prost = {workspace = true}

cli/src/command/bundle.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
use code0_definition_reader::parser::Parser;
2+
use prost::Message;
3+
use std::fs;
4+
use std::io::Write;
5+
6+
pub fn bundle(path: Option<String>, out: Option<String>) {
7+
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
8+
let out_path = out.unwrap_or_else(|| "./bundles".to_string());
9+
match fs::create_dir_all(&out_path) {
10+
Ok(_) => {}
11+
Err(err) => {
12+
panic!("Error creating output directory: {:?}", err);
13+
}
14+
}
15+
16+
let parser = match Parser::from_path(dir_path.as_str()) {
17+
Some(reader) => reader,
18+
None => {
19+
panic!("Error reading definitions");
20+
}
21+
};
22+
23+
for feature in parser.features {
24+
feature.data_types.iter().for_each(|data_type| {
25+
let mut buf = Vec::new();
26+
if let Ok(_) = data_type.encode(&mut buf) {
27+
let path = format!(
28+
"{}/{}_{}_{}.pb",
29+
&out_path,
30+
feature.name,
31+
"data_type",
32+
data_type.identifier.to_lowercase()
33+
);
34+
fs::File::create(&path)
35+
.expect("abc")
36+
.write_all(&buf)
37+
.expect("a");
38+
}
39+
});
40+
41+
feature.flow_types.iter().for_each(|flow_type| {
42+
let mut buf = Vec::new();
43+
if let Ok(_) = flow_type.encode(&mut buf) {
44+
let path = format!(
45+
"{}/{}_{}_{}.pb",
46+
&out_path,
47+
feature.name,
48+
"flow_type",
49+
flow_type.identifier.to_lowercase()
50+
);
51+
fs::File::create(&path)
52+
.expect("abc")
53+
.write_all(&buf)
54+
.expect("a");
55+
}
56+
});
57+
58+
feature.runtime_functions.iter().for_each(|function| {
59+
let mut buf = Vec::new();
60+
if let Ok(_) = function.encode(&mut buf) {
61+
let path = format!(
62+
"{}/{}_{}_{}.pb",
63+
&out_path,
64+
feature.name,
65+
"function",
66+
function.runtime_name.to_lowercase()
67+
);
68+
fs::File::create(&path)
69+
.expect("abc")
70+
.write_all(&buf)
71+
.expect("a");
72+
}
73+
});
74+
}
75+
}

cli/src/command/definition.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::formatter::{info, success};
22
use code0_definition_reader::parser::Parser;
33
use colored::Colorize;
4+
use prost::Message;
5+
use tucana::shared::DefinitionDataType;
46

57
pub fn search_definition(name: String, path: Option<String>) {
68
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());

cli/src/command/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod bundle;
12
pub mod definition;
23
pub mod download;
34
pub mod feature;

cli/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,20 @@ enum Commands {
5353
#[clap(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
5454
features: Option<Vec<String>>,
5555
},
56+
Bundle {
57+
#[arg(short, long)]
58+
path: Option<String>,
59+
#[arg(short, long)]
60+
out: Option<String>,
61+
},
5662
}
5763

5864
#[tokio::main]
5965
async fn main() {
6066
let cli = Cli::parse();
6167

6268
match cli.command {
69+
Commands::Bundle { path, out } => command::bundle::bundle(path, out),
6370
Commands::Report { path } => command::report::report_errors(path),
6471
Commands::Feature { name, path } => command::feature::search_feature(name, path),
6572
Commands::Definition { name, path } => command::definition::search_definition(name, path),

definitions/http/flow_type/http.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
{
4141
"identifier": "HTTP_HOST",
4242
"unique": false,
43-
"data_type_identifier": "HTTP_HOST",
43+
"data_type_identifier": "TEXT",
4444
"default_value": null,
4545
"name": [
4646
{

0 commit comments

Comments
 (0)