From 99c200b161a4ebb4bc98f1106245d17312099b4e Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Tue, 14 Jan 2025 13:08:38 -0500 Subject: [PATCH 1/5] feat(cli): cmd `schema:check` result json output --- packages/libraries/cli/src/commands/schema/check.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/libraries/cli/src/commands/schema/check.ts b/packages/libraries/cli/src/commands/schema/check.ts index 11d36bec4c..8a77901912 100644 --- a/packages/libraries/cli/src/commands/schema/check.ts +++ b/packages/libraries/cli/src/commands/schema/check.ts @@ -1,3 +1,4 @@ +import fs from 'node:fs'; import { Args, Errors, Flags } from '@oclif/core'; import Command from '../../base-command'; import { graphql } from '../../gql'; @@ -115,6 +116,11 @@ export default class SchemaCheck extends Command { version: '0.21.0', }, }), + experimentalJsonFile: Flags.string({ + name: 'experimental-json-file', + description: + "File path to output a JSON file containing the command's result. Useful for e.g. CI scripting with `jq`.", + }), forceSafe: Flags.boolean({ description: 'mark the check as safe, breaking changes are expected', }), @@ -233,6 +239,10 @@ export default class SchemaCheck extends Command { }, }); + if (flags.experimentalJsonFile) { + fs.writeFileSync(flags.experimentalJsonFile, JSON.stringify(result, null, 2)); + } + if (result.schemaCheck.__typename === 'SchemaCheckSuccess') { const changes = result.schemaCheck.changes; if (result.schemaCheck.initial) { From 03c349dbc0ab33c2fcbc6edb9e4b1588dd5d5c82 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Wed, 15 Jan 2025 08:57:45 -0500 Subject: [PATCH 2/5] changeset --- .changeset/seven-stingrays-tell.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .changeset/seven-stingrays-tell.md diff --git a/.changeset/seven-stingrays-tell.md b/.changeset/seven-stingrays-tell.md new file mode 100644 index 0000000000..cbad4d5ead --- /dev/null +++ b/.changeset/seven-stingrays-tell.md @@ -0,0 +1,14 @@ +--- +'@graphql-hive/cli': minor +--- + +Add experimental json file flag to command `schema:check`. + +On the `schema:check` command, you can now use the flag `--experimental-json-file` to output a JSON file containing the command's result. + +This experimental feature is designed to help users with scripting, typically in CI/CD pipelines. + +Please note that this is an experimental feature, and therefore is: + +1. likely to change or be removed in a future version +2. not covered by semantic versioning. From e087dbb9d35caa2ec614d6e1a90481169021fcde Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Wed, 15 Jan 2025 08:58:57 -0500 Subject: [PATCH 3/5] consistent use of "you" --- .changeset/seven-stingrays-tell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/seven-stingrays-tell.md b/.changeset/seven-stingrays-tell.md index cbad4d5ead..bca153e8e6 100644 --- a/.changeset/seven-stingrays-tell.md +++ b/.changeset/seven-stingrays-tell.md @@ -6,7 +6,7 @@ Add experimental json file flag to command `schema:check`. On the `schema:check` command, you can now use the flag `--experimental-json-file` to output a JSON file containing the command's result. -This experimental feature is designed to help users with scripting, typically in CI/CD pipelines. +This experimental feature is designed to help you with scripting, typically in CI/CD pipelines. Please note that this is an experimental feature, and therefore is: From 8f2734673572fa66a962569a1f8ca46470de7b31 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Wed, 15 Jan 2025 08:59:44 -0500 Subject: [PATCH 4/5] not a boolean flag --- .changeset/seven-stingrays-tell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/seven-stingrays-tell.md b/.changeset/seven-stingrays-tell.md index bca153e8e6..6f3448cef3 100644 --- a/.changeset/seven-stingrays-tell.md +++ b/.changeset/seven-stingrays-tell.md @@ -4,7 +4,7 @@ Add experimental json file flag to command `schema:check`. -On the `schema:check` command, you can now use the flag `--experimental-json-file` to output a JSON file containing the command's result. +On the `schema:check` command, you can now use the flag `--experimental-json-file ./path/to/file.json` to output a JSON file containing the command's result. This experimental feature is designed to help you with scripting, typically in CI/CD pipelines. From ca9ae66ebba1089f0cb6d9a47a29b49b4ccfb121 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Wed, 15 Jan 2025 09:00:07 -0500 Subject: [PATCH 5/5] better name --- .changeset/seven-stingrays-tell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/seven-stingrays-tell.md b/.changeset/seven-stingrays-tell.md index 6f3448cef3..0ae3a52129 100644 --- a/.changeset/seven-stingrays-tell.md +++ b/.changeset/seven-stingrays-tell.md @@ -4,7 +4,7 @@ Add experimental json file flag to command `schema:check`. -On the `schema:check` command, you can now use the flag `--experimental-json-file ./path/to/file.json` to output a JSON file containing the command's result. +On the `schema:check` command, you can now use the flag `--experimental-json-file ./path/to/schema-check-result.json` to output a JSON file containing the command's result. This experimental feature is designed to help you with scripting, typically in CI/CD pipelines.