From 511a1883cf83ffc19b39e8d01e70fe75cac3fc32 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 9 Jan 2025 12:04:46 -0400 Subject: [PATCH] Simplify indexing output a bit (#110) Signed-off-by: Juan Cruz Viotti --- src/index/index.cc | 19 ++++++++----------- .../cli/common/index/invalid-configuration.sh | 4 ++-- test/cli/common/index/invalid-schema.sh | 13 +++++-------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/index/index.cc b/src/index/index.cc index 97c5e0b..48c2102 100644 --- a/src/index/index.cc +++ b/src/index/index.cc @@ -85,9 +85,7 @@ static auto index(sourcemeta::jsontoolkit::FlatFileSchemaResolver &resolver, .canonicalize()}; const auto collection_base_uri_string{collection_base_uri.recompose()}; - std::cerr << "-- Processing collection: " << schema_entry.first << "\n"; - std::cerr << "Base directory: " << collection_path.string() << "\n"; - std::cerr << "Base URI: " << collection_base_uri_string << "\n"; + std::cerr << "Discovering schemas at: " << collection_path.string() << "\n"; const std::optional default_dialect{ schema_entry.second.defines("defaultDialect") @@ -104,7 +102,7 @@ static auto index(sourcemeta::jsontoolkit::FlatFileSchemaResolver &resolver, continue; } - std::cerr << "Found schema: " << entry.path().string() << "\n"; + std::cerr << "-- Found schema: " << entry.path().string() << "\n"; // Calculate a default identifier for the schema through their file system // location, to accomodate for schema collections that purely rely on @@ -124,11 +122,11 @@ static auto index(sourcemeta::jsontoolkit::FlatFileSchemaResolver &resolver, default_identifier.str())}; auto identifier_uri{ sourcemeta::jsontoolkit::URI{current_identifier}.canonicalize()}; - std::cerr << "Current identifier: " << identifier_uri.recompose() << "\n"; + std::cerr << identifier_uri.recompose(); identifier_uri.relative_to(collection_base_uri); if (identifier_uri.is_absolute()) { - std::cout << "Cannot resolve the schema identifier against the " - "collection base\n"; + std::cout << "\nerror: Cannot resolve the schema identifier against " + "the collection base\n"; return EXIT_FAILURE; } @@ -139,7 +137,7 @@ static auto index(sourcemeta::jsontoolkit::FlatFileSchemaResolver &resolver, // extension, as we want to use the non-extension URI to // potentially metadata about schemas, etc "json")}; - std::cerr << "Rebased identifier: " << new_identifier << "\n"; + std::cerr << " => " << new_identifier << "\n"; resolver.reidentify(current_identifier, new_identifier); } } @@ -219,9 +217,8 @@ static auto index_main(const std::string_view &program, const auto configuration_path{std::filesystem::canonical(arguments[0])}; const auto output{std::filesystem::weakly_canonical(arguments[1])}; - std::cerr << "-- Using configuration: " << configuration_path.string() - << "\n"; - std::cerr << "-- Writing output to: " << output.string() << "\n"; + std::cerr << "Using configuration: " << configuration_path.string() << "\n"; + std::cerr << "Writing output to: " << output.string() << "\n"; const auto configuration_schema{sourcemeta::jsontoolkit::parse( std::string{sourcemeta::registry::SCHEMA_CONFIGURATION})}; diff --git a/test/cli/common/index/invalid-configuration.sh b/test/cli/common/index/invalid-configuration.sh index ebe55bd..96672af 100755 --- a/test/cli/common/index/invalid-configuration.sh +++ b/test/cli/common/index/invalid-configuration.sh @@ -20,8 +20,8 @@ EOF test "$CODE" = "1" || exit 1 cat << EOF > "$TMP/expected.txt" --- Using configuration: $(realpath "$TMP")/configuration.json --- Writing output to: $(realpath "$TMP")/output +Using configuration: $(realpath "$TMP")/configuration.json +Writing output to: $(realpath "$TMP")/output error: Invalid configuration The object value was expected to define properties "port", "schemas", and "url" but did not define the property "url" at instance location "" diff --git a/test/cli/common/index/invalid-schema.sh b/test/cli/common/index/invalid-schema.sh index d9b64ed..1ca0601 100755 --- a/test/cli/common/index/invalid-schema.sh +++ b/test/cli/common/index/invalid-schema.sh @@ -34,14 +34,11 @@ EOF test "$CODE" = "1" || exit 1 cat << EOF > "$TMP/expected.txt" --- Using configuration: $(realpath "$TMP")/configuration.json --- Writing output to: $(realpath "$TMP")/output --- Processing collection: example/schemas -Base directory: $(realpath "$TMP")/schemas -Base URI: https://example.com/ -Found schema: $(realpath "$TMP")/schemas/test.json -Current identifier: https://example.com/test.json -Rebased identifier: https://sourcemeta.com/example/schemas/test.json +Using configuration: $(realpath "$TMP")/configuration.json +Writing output to: $(realpath "$TMP")/output +Discovering schemas at: $(realpath "$TMP")/schemas +-- Found schema: $(realpath "$TMP")/schemas/test.json +https://example.com/test.json => https://sourcemeta.com/example/schemas/test.json -- Processing schema: https://sourcemeta.com/example/schemas/test.json Schema output: $(realpath "$TMP")/output/schemas/example/schemas/test.json Compiling metaschema: http://json-schema.org/draft-07/schema#