-
-
Notifications
You must be signed in to change notification settings - Fork 4
Add a --configuration option to the index binary
#628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,9 +102,10 @@ static auto index_main(const std::string_view &program, | |
| const auto raw_configuration{sourcemeta::one::Configuration::read( | ||
| configuration_path, SOURCEMETA_ONE_COLLECTIONS)}; | ||
|
|
||
| if (app.contains("verbose")) { | ||
| sourcemeta::core::prettify(raw_configuration, std::cerr); | ||
| std::cerr << "\n"; | ||
| if (app.contains("configuration")) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents |
||
| sourcemeta::core::prettify(raw_configuration, std::cout); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Severity: low 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| std::cout << "\n"; | ||
| return EXIT_SUCCESS; | ||
| } | ||
|
|
||
| auto configuration{sourcemeta::one::Configuration::parse(raw_configuration)}; | ||
|
|
@@ -600,6 +601,7 @@ auto main(int argc, char *argv[]) noexcept -> int { | |
| app.option("concurrency", {"c"}); | ||
| app.flag("verbose", {"v"}); | ||
| app.flag("profile", {"p"}); | ||
| app.flag("configuration", {"g"}); | ||
| app.parse(argc, argv); | ||
| const std::string_view program{argv[0]}; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << EOF > "$TMP/one.json" | ||
| { | ||
| "url": "https://sourcemeta.com/", | ||
| "contents": { | ||
| "example": { | ||
| "contents": { | ||
| "schemas": { | ||
| "baseUri": "https://example.com/", | ||
| "path": "./schemas" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| mkdir "$TMP/schemas" | ||
|
|
||
| cat << 'EOF' > "$TMP/schemas/foo.json" | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "https://example.com/foo" | ||
| } | ||
| EOF | ||
|
|
||
| "$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt" | ||
| cat << EOF > "$TMP/expected.txt" | ||
| { | ||
| "url": "https://sourcemeta.com/", | ||
| "contents": { | ||
| "example": { | ||
| "contents": { | ||
| "schemas": { | ||
| "baseUri": "https://example.com/", | ||
| "path": "$(realpath "$TMP")/schemas" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "html": { | ||
| "name": "Sourcemeta", | ||
| "description": "The next-generation JSON Schema platform" | ||
| } | ||
| } | ||
| EOF | ||
| diff "$TMP/output.txt" "$TMP/expected.txt" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << EOF > "$TMP/one.json" | ||
| { | ||
| "url": "https://sourcemeta.com/", | ||
| "contents": { | ||
| "example": { | ||
| "contents": { | ||
| "schemas": { | ||
| "baseUri": "https://example.com/", | ||
| "path": "./schemas" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| mkdir "$TMP/schemas" | ||
|
|
||
| cat << 'EOF' > "$TMP/schemas/foo.json" | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "https://example.com/foo" | ||
| } | ||
| EOF | ||
|
|
||
| "$1" "$TMP/one.json" "$TMP/output" -g | tail -n +2 > "$TMP/output.txt" | ||
| cat << EOF > "$TMP/expected.txt" | ||
| { | ||
| "url": "https://sourcemeta.com/", | ||
| "contents": { | ||
| "example": { | ||
| "contents": { | ||
| "schemas": { | ||
| "baseUri": "https://example.com/", | ||
| "path": "$(realpath "$TMP")/schemas" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "html": { | ||
| "name": "Sourcemeta", | ||
| "description": "The next-generation JSON Schema platform" | ||
| } | ||
| } | ||
| EOF | ||
| diff "$TMP/output.txt" "$TMP/expected.txt" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << EOF > "$TMP/one.json" | ||
| { | ||
| "url": "https://example.com/", | ||
| "extends": [ "@sourcemeta/std/v0" ] | ||
| } | ||
| EOF | ||
|
|
||
| "$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The pipeline only checks Prompt for AI agents |
||
|
|
||
| cat << EOF > "$TMP/expected.txt" | ||
| { | ||
| "contents": { | ||
| "sourcemeta": { | ||
| "title": "Sourcemeta", | ||
| "description": "A provider of premium tooling and services to support JSON Schema use in production", | ||
| "email": "hello@sourcemeta.com", | ||
| "github": "sourcemeta", | ||
| "website": "https://www.sourcemeta.com", | ||
| "contents": { | ||
| "std": { | ||
| "title": "The JSON Schema Standard Library", | ||
| "description": "A growing collection of hand-crafted high-quality schemas by Sourcemeta", | ||
| "email": "hello@sourcemeta.com", | ||
| "github": "sourcemeta/std", | ||
| "website": "https://www.sourcemeta/products/std", | ||
| "contents": { | ||
| "v0": { | ||
| "x-sourcemeta-one:provenance": "@sourcemeta/std/v0", | ||
| "path": "$ONE_PREFIX/share/sourcemeta/one/collections/sourcemeta/std/v0/schemas/2020-12", | ||
| "baseUri": "https://example.com/" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "url": "https://example.com/", | ||
| "html": { | ||
| "name": "Sourcemeta", | ||
| "description": "The next-generation JSON Schema platform" | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| diff "$TMP/output.txt" "$TMP/expected.txt" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--configurationreturns before the--urloverride block later inindex_main, so invocations like... --url <...> --configurationwill print the non-overridden URL (and other derived values) rather than the effective configuration; the Makefile now calls this combination insandbox-index. Is that the intended behavior for the new option?Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.