From bd921770fdbaa78c3f1b37e72636c6c73461faad Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Mon, 29 Sep 2025 15:03:28 +0300 Subject: [PATCH] refactor: Dynamically determine hero directory - Get script directory to find herolib root - Determine hero_dir based on script location - Verify hero_dir and hero.v existence - Print used hero directory --- cli/compile.vsh | 19 +++++++++++++++++-- lib/schemas/openrpc/model.v | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cli/compile.vsh b/cli/compile.vsh index fa1558c9..de2765ad 100755 --- a/cli/compile.vsh +++ b/cli/compile.vsh @@ -30,8 +30,23 @@ if additional_args.len > 0 { exit(1) } -// Change to the hero directory -hero_dir := os.join_path(os.home_dir(), 'code/github/incubaid/herolib/cli') +// Determine the hero directory dynamically +// Get the directory where this script is located +script_dir := os.dir(os.executable()) +// The script is in cli/, so the herolib root is one level up +herolib_root := os.dir(script_dir) +hero_dir := os.join_path(herolib_root, 'cli') + +// Verify the directory exists and contains hero.v +if !os.exists(hero_dir) { + panic('Hero CLI directory not found: ${hero_dir}') +} +hero_v_path := os.join_path(hero_dir, 'hero.v') +if !os.exists(hero_v_path) { + panic('hero.v not found in: ${hero_dir}') +} + +println('Using hero directory: ${hero_dir}') os.chdir(hero_dir) or { panic('Failed to change directory to ${hero_dir}: ${err}') } // Set HEROPATH based on OS diff --git a/lib/schemas/openrpc/model.v b/lib/schemas/openrpc/model.v index 0fb0f74f..afaf609e 100644 --- a/lib/schemas/openrpc/model.v +++ b/lib/schemas/openrpc/model.v @@ -2,6 +2,9 @@ module openrpc import freeflowuniverse.herolib.schemas.jsonschema { Reference, SchemaRef } +// Generic type for any value in examples +type Any = string | int | f64 | bool | map[string]Any | []Any + // This is the root object of the OpenRPC document. // The contents of this object represent a whole OpenRPC document. // How this object is constructed or stored is outside the scope of the OpenRPC Specification.