From ebba3233668779fa510a7d059c027eea43137929 Mon Sep 17 00:00:00 2001 From: stefan-gorules <127550877+stefan-gorules@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:45:22 +0200 Subject: [PATCH] fix: rename templates crate (#140) * fix: rename templates crate * fix: update workflow --- actions/cargo-version-action/dist/index.js | 4 ++-- actions/cargo-version-action/src/cargo.ts | 4 ++-- actions/cargo-version-action/src/index.spec.ts | 2 +- bindings/c/Cargo.toml | 2 +- bindings/c/src/expression.rs | 2 +- bindings/nodejs/Cargo.toml | 2 +- bindings/nodejs/src/expression.rs | 2 +- bindings/nodejs/src/types.rs | 2 +- bindings/python/Cargo.toml | 2 +- bindings/python/src/expression.rs | 2 +- bindings/python/src/types.rs | 2 +- core/engine/Cargo.toml | 2 +- core/engine/src/handler/custom_node_adapter.rs | 4 ++-- core/template/Cargo.toml | 2 +- core/template/tests/template.rs | 2 +- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/actions/cargo-version-action/dist/index.js b/actions/cargo-version-action/dist/index.js index f473737a..e4fc0a08 100644 --- a/actions/cargo-version-action/dist/index.js +++ b/actions/cargo-version-action/dist/index.js @@ -11270,12 +11270,12 @@ var toml = __nccwpck_require__(4920); const versionRegex = /version = "[0-9]+\.[0-9]+\.[0-9]+"$/im; const expressionDep = /zen-expression =.*$/im; -const templateDep = /zen-template =.*$/im; +const templateDep = /zen-tmpl =.*$/im; const updateCargoContents = (contents, { version }) => { return contents .replace(versionRegex, `version = "${version}"`) .replace(expressionDep, `zen-expression = { path = "../expression", version = "${version}" }`) - .replace(templateDep, `zen-template = { path = "../template", version = "${version}" }`); + .replace(templateDep, `zen-tmpl = { path = "../template", version = "${version}" }`); }; const getCargoVersion = (contents) => { var _a; diff --git a/actions/cargo-version-action/src/cargo.ts b/actions/cargo-version-action/src/cargo.ts index 5ab098c1..eb3efdb1 100644 --- a/actions/cargo-version-action/src/cargo.ts +++ b/actions/cargo-version-action/src/cargo.ts @@ -6,13 +6,13 @@ type UpdateCargoOptions = { const versionRegex = /version = "[0-9]+\.[0-9]+\.[0-9]+"$/im; const expressionDep = /zen-expression =.*$/im; -const templateDep = /zen-template =.*$/im; +const templateDep = /zen-tmpl =.*$/im; export const updateCargoContents = (contents: string, { version }: UpdateCargoOptions): string => { return contents .replace(versionRegex, `version = "${version}"`) .replace(expressionDep, `zen-expression = { path = "../expression", version = "${version}" }`) - .replace(templateDep, `zen-template = { path = "../template", version = "${version}" }`); + .replace(templateDep, `zen-tmpl = { path = "../template", version = "${version}" }`); }; export const getCargoVersion = (contents: string): string => { diff --git a/actions/cargo-version-action/src/index.spec.ts b/actions/cargo-version-action/src/index.spec.ts index c95b6d49..2f78f9e5 100644 --- a/actions/cargo-version-action/src/index.spec.ts +++ b/actions/cargo-version-action/src/index.spec.ts @@ -29,7 +29,7 @@ const makeToml = ({ version }): string => ` futures = "0.3.27" v8 = { version = "0.66.0" } zen-expression = { path = "../expression", version = "${version}" } - zen-template = { path = "../template", version = "${version}" } + zen-tmpl = { path = "../template", version = "${version}" } `; describe('GitHub Action', () => { diff --git a/bindings/c/Cargo.toml b/bindings/c/Cargo.toml index 9b8f74f8..30a25914 100644 --- a/bindings/c/Cargo.toml +++ b/bindings/c/Cargo.toml @@ -15,7 +15,7 @@ strum = { version = "0.26.1", features = ["derive"] } futures = "0.3.28" zen-engine = { path = "../../core/engine" } zen-expression = { path = "../../core/expression" } -zen-template = { path = "../../core/template" } +zen-tmpl = { path = "../../core/template" } [lib] crate-type = ["staticlib"] diff --git a/bindings/c/src/expression.rs b/bindings/c/src/expression.rs index 352cbbd1..9e49753d 100644 --- a/bindings/c/src/expression.rs +++ b/bindings/c/src/expression.rs @@ -90,7 +90,7 @@ pub extern "C" fn zen_evaluate_template( return ZenResult::error(ZenError::JsonDeserializationFailed); }; - let result = match zen_template::render(template_str, &context_val) { + let result = match zen_tmpl::render(template_str, &context_val) { Ok(r) => r, Err(err) => { return ZenResult::error(ZenError::TemplateEngineError { diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml index 1ea90ff5..31311890 100644 --- a/bindings/nodejs/Cargo.toml +++ b/bindings/nodejs/Cargo.toml @@ -16,7 +16,7 @@ serde_json = { workspace = true } futures = { workspace = true } zen-engine = { path = "../../core/engine" } zen-expression = { path = "../../core/expression" } -zen-template = { path = "../../core/template" } +zen-tmpl = { path = "../../core/template" } serde = { workspace = true, features = ["derive"] } json_dotpath = { workspace = true } diff --git a/bindings/nodejs/src/expression.rs b/bindings/nodejs/src/expression.rs index 0f258155..6c786560 100644 --- a/bindings/nodejs/src/expression.rs +++ b/bindings/nodejs/src/expression.rs @@ -24,7 +24,7 @@ pub fn evaluate_unary_expression_sync(expression: String, context: Value) -> nap #[allow(dead_code)] #[napi] pub fn render_template_sync(template: String, context: Value) -> napi::Result { - Ok(zen_template::render(template.as_str(), &context) + Ok(zen_tmpl::render(template.as_str(), &context) .map_err(|e| anyhow!(serde_json::to_string(&e).unwrap_or_else(|_| e.to_string())))?) } diff --git a/bindings/nodejs/src/types.rs b/bindings/nodejs/src/types.rs index 518dfb5f..7851f282 100644 --- a/bindings/nodejs/src/types.rs +++ b/bindings/nodejs/src/types.rs @@ -104,7 +104,7 @@ impl ZenEngineHandlerRequest { return Ok(selected_value); }; - let template_value = zen_template::render(template.as_str(), &self.input) + let template_value = zen_tmpl::render(template.as_str(), &self.input) .map_err(|e| anyhow!(serde_json::to_string(&e).unwrap_or_else(|_| e.to_string())))?; Ok(template_value) diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index 392d8eb4..8335b3b1 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -20,4 +20,4 @@ serde_json = { workspace = true } futures = { workspace = true } zen-engine = { path = "../../core/engine" } zen-expression = { path = "../../core/expression" } -zen-template = { path = "../../core/template" } \ No newline at end of file +zen-tmpl = { path = "../../core/template" } \ No newline at end of file diff --git a/bindings/python/src/expression.rs b/bindings/python/src/expression.rs index c8c53ecb..a545d2ce 100644 --- a/bindings/python/src/expression.rs +++ b/bindings/python/src/expression.rs @@ -38,7 +38,7 @@ pub fn evaluate_unary_expression(expression: String, ctx: &PyDict) -> PyResult PyResult { let context: Value = depythonize(ctx).context("Failed to convert context")?; - let result = zen_template::render(template.as_str(), &context) + let result = zen_tmpl::render(template.as_str(), &context) .map_err(|e| anyhow!(serde_json::to_string(&e).unwrap_or_else(|_| e.to_string())))?; Ok(PyValue(result).to_object(py)) diff --git a/bindings/python/src/types.rs b/bindings/python/src/types.rs index 42a6852c..20acb614 100644 --- a/bindings/python/src/types.rs +++ b/bindings/python/src/types.rs @@ -73,7 +73,7 @@ impl PyNodeRequest { return Ok(PyValue(selected_value).to_object(py)); }; - let template_value = zen_template::render(template.as_str(), &self.inner_input) + let template_value = zen_tmpl::render(template.as_str(), &self.inner_input) .map_err(|e| anyhow!(serde_json::to_string(&e).unwrap_or_else(|_| e.to_string())))?; Ok(PyValue(template_value).to_object(py)) diff --git a/core/engine/Cargo.toml b/core/engine/Cargo.toml index 825278bc..760417ba 100644 --- a/core/engine/Cargo.toml +++ b/core/engine/Cargo.toml @@ -26,7 +26,7 @@ futures = { workspace = true } rquickjs = { version = "0.4.3", features = ["macro", "loader", "rust-alloc"] } itertools = "0.12.1" zen-expression = { path = "../expression", version = "0.20.0" } -zen-template = { path = "../template", version = "0.20.0" } +zen-tmpl = { path = "../template", version = "0.20.0" } [dev-dependencies] tokio = { version = "1.35.1", features = ["rt", "macros"] } diff --git a/core/engine/src/handler/custom_node_adapter.rs b/core/engine/src/handler/custom_node_adapter.rs index 3279c63a..47d9ec5e 100644 --- a/core/engine/src/handler/custom_node_adapter.rs +++ b/core/engine/src/handler/custom_node_adapter.rs @@ -4,7 +4,7 @@ use anyhow::anyhow; use json_dotpath::DotPaths; use serde::Serialize; use serde_json::Value; -use zen_template::TemplateRenderError; +use zen_tmpl::TemplateRenderError; pub trait CustomNodeAdapter { fn handle( @@ -50,7 +50,7 @@ impl<'a> CustomNodeRequest<'a> { return Ok(Some(selected_value)); }; - let template_value = zen_template::render(template.as_str(), &self.input)?; + let template_value = zen_tmpl::render(template.as_str(), &self.input)?; Ok(Some(template_value)) } diff --git a/core/template/Cargo.toml b/core/template/Cargo.toml index c0ae10d7..25be7340 100644 --- a/core/template/Cargo.toml +++ b/core/template/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["GoRules Team "] description = "Zen Template Language" -name = "zen-template" +name = "zen-tmpl" license = "MIT" version = "0.20.0" edition = "2021" diff --git a/core/template/tests/template.rs b/core/template/tests/template.rs index 43646c5e..30b676ae 100644 --- a/core/template/tests/template.rs +++ b/core/template/tests/template.rs @@ -1,5 +1,5 @@ use serde_json::{json, Value}; -use zen_template::render; +use zen_tmpl::render; #[test] fn test_values_types() {