Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
22 changes: 20 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,35 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v5

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Build project
run: cargo run bundle --path ../definitions --out ../bundles
working-directory: "./cli"

- name: Archive definitions folder
run: |
zip -r definitions.zip definitions
zip -r bundles.zip bundles

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
files: |
definitions.zip
bundles.zip
generate_release_notes: true
make_latest: true
env:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
**/node_modules
.idea
reader/ts/src/*.js
reader/ts/build
reader/ts/build
bundles
reader/**/*.js
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ tokio = "1.47.0"
futures = "0.3.31"
zip = "6.0.0"
bytes = "1.10.1"
prost = "0.14.1"
code0-definition-reader= "0.0.13"
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] }
futures = { workspace = true }
zip = { workspace = true }
bytes = { workspace = true }
prost = {workspace = true}
75 changes: 75 additions & 0 deletions cli/src/command/bundle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use code0_definition_reader::parser::Parser;
use prost::Message;
use std::fs;
use std::io::Write;

pub fn bundle(path: Option<String>, out: Option<String>) {
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
let out_path = out.unwrap_or_else(|| "./bundles".to_string());
match fs::create_dir_all(&out_path) {
Ok(_) => {}
Err(err) => {
panic!("Error creating output directory: {:?}", err);
}
}

let parser = match Parser::from_path(dir_path.as_str()) {
Some(reader) => reader,
None => {
panic!("Error reading definitions");
}
};

for feature in parser.features {
feature.data_types.iter().for_each(|data_type| {
let mut buf = Vec::new();
if let Ok(_) = data_type.encode(&mut buf) {
let path = format!(
"{}/{}_{}_{}.pb",
&out_path,
feature.name,
"data_type",
data_type.identifier.to_lowercase()
);
fs::File::create(&path)
.expect("abc")
.write_all(&buf)
.expect("a");
}
});

feature.flow_types.iter().for_each(|flow_type| {
let mut buf = Vec::new();
if let Ok(_) = flow_type.encode(&mut buf) {
let path = format!(
"{}/{}_{}_{}.pb",
&out_path,
feature.name,
"flow_type",
flow_type.identifier.to_lowercase()
);
fs::File::create(&path)
.expect("abc")
.write_all(&buf)
.expect("a");
}
});

feature.runtime_functions.iter().for_each(|function| {
let mut buf = Vec::new();
if let Ok(_) = function.encode(&mut buf) {
let path = format!(
"{}/{}_{}_{}.pb",
&out_path,
feature.name,
"function",
function.runtime_name.to_lowercase()
);
fs::File::create(&path)
.expect("abc")
.write_all(&buf)
.expect("a");
}
});
}
}
2 changes: 2 additions & 0 deletions cli/src/command/definition.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::formatter::{info, success};
use code0_definition_reader::parser::Parser;
use colored::Colorize;
use prost::Message;
use tucana::shared::DefinitionDataType;

pub fn search_definition(name: String, path: Option<String>) {
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
Expand Down
1 change: 1 addition & 0 deletions cli/src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod bundle;
pub mod definition;
pub mod download;
pub mod feature;
Expand Down
7 changes: 7 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ enum Commands {
#[clap(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
features: Option<Vec<String>>,
},
Bundle {
#[arg(short, long)]
path: Option<String>,
#[arg(short, long)]
out: Option<String>,
},
}

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

match cli.command {
Commands::Bundle { path, out } => command::bundle::bundle(path, out),
Commands::Report { path } => command::report::report_errors(path),
Commands::Feature { name, path } => command::feature::search_feature(name, path),
Commands::Definition { name, path } => command::definition::search_definition(name, path),
Expand Down
2 changes: 1 addition & 1 deletion definitions/http/flow_type/http.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
"identifier": "HTTP_HOST",
"unique": false,
"data_type_identifier": "HTTP_HOST",
"data_type_identifier": "TEXT",
"default_value": null,
"name": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
},
{
"data_type_identifier": {
"type": null
"type": {
"DataTypeIdentifier": "NUMBER"
}
},
"runtime_name": "index",
"default_value": null,
Expand All @@ -70,7 +72,9 @@
}
],
"return_type_identifier": {
"type": null
"type": {
"GenericKey": "R"
}
},
"throws_error": false,
"generic_keys": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
},
{
"data_type_identifier": {
"type": null
"type": {
"GenericKey": "R"
}
},
"runtime_name": "item",
"default_value": null,
Expand Down
4 changes: 2 additions & 2 deletions reader/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { Definition } from './src/parser.js';
export type { Feature, MetaType, Meta } from './src/types.js';
export { Definition } from './src/parser.ts';
export type { Feature } from './src/types.ts';
Loading