From a0d1f7f9af7a1acd3eb69be96ae18e6121a9d61c Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 16 Jun 2021 08:35:19 -0700 Subject: [PATCH] Remove gemfile and ruby code (#19910) --- Gemfile | 5 - Gemfile.lock | 20 ---- script/README.md | 10 +- script/graphql/update-files.js | 22 +--- .../utils/remove-hidden-schema-members.rb | 108 ------------------ 5 files changed, 4 insertions(+), 161 deletions(-) delete mode 100644 Gemfile delete mode 100644 Gemfile.lock delete mode 100755 script/graphql/utils/remove-hidden-schema-members.rb diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 9a59ddbfa26e..000000000000 --- a/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source 'http://rubygems.org' -# ruby '2.4' - -gem 'graphql', '1.10.6' -gem 'graphql-schema_comparator', '~> 1.0.0' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 70cca0b44d5f..000000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,20 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - graphql (1.10.6) - graphql-schema_comparator (1.0.0) - bundler (>= 1.14) - graphql (~> 1.10) - thor (>= 0.19, < 2.0) - thor (1.0.1) - -PLATFORMS - ruby - x86_64-linux - -DEPENDENCIES - graphql (= 1.10.6) - graphql-schema_comparator (~> 1.0.0) - -BUNDLED WITH - 2.2.1 diff --git a/script/README.md b/script/README.md index d511512f3e39..b57a0b720de5 100644 --- a/script/README.md +++ b/script/README.md @@ -265,14 +265,6 @@ Given: /enterprise/admin/installation/upgrading-github-enterprise Returns: /ente ### [`graphql/utils/process-upcoming-changes.js`](graphql/utils/process-upcoming-changes.js) - ---- - - -### [`graphql/utils/remove-hidden-schema-members.rb`](graphql/utils/remove-hidden-schema-members.rb) - - - --- @@ -503,4 +495,4 @@ This script crawls the script directory, hooks on special comment markers in eac ---- \ No newline at end of file +--- diff --git a/script/graphql/update-files.js b/script/graphql/update-files.js index 4032d8b4c9b2..1bb83f67adfe 100755 --- a/script/graphql/update-files.js +++ b/script/graphql/update-files.js @@ -32,10 +32,6 @@ try { process.exit(1) } -// TODO this step is only required as long as we support GHE versions *OLDER THAN* 2.21 -// as soon as 2.20 is deprecated on 2021-02-11, we can remove all graphql-ruby filtering -const removeHiddenMembersScript = path.join(__dirname, './utils/remove-hidden-schema-members.rb') - const versionsToBuild = Object.keys(allVersions) const currentLanguage = 'en' @@ -81,9 +77,8 @@ async function main () { const schemaPath = getDataFilepath('schemas', graphqlVersion) const previousSchemaString = fs.readFileSync(schemaPath, 'utf8') const latestSchema = await getRemoteRawContent(schemaPath, graphqlVersion) - const safeForPublicSchema = removeHiddenMembers(schemaPath, latestSchema) - updateFile(schemaPath, safeForPublicSchema) - const schemaJsonPerVersion = await processSchemas(safeForPublicSchema, safeForPublicPreviews) + updateFile(schemaPath, latestSchema) + const schemaJsonPerVersion = await processSchemas(latestSchema, safeForPublicPreviews) updateStaticFile(schemaJsonPerVersion, path.join(graphqlStaticDir, `schema-${graphqlVersion}.json`)) // Add some version specific data to the context @@ -103,7 +98,7 @@ async function main () { // The Changelog is only build for free-pro-team@latest const changelogEntry = await createChangelogEntry( previousSchemaString, - safeForPublicSchema, + latestSchema, safeForPublicPreviews, previousUpcomingChanges.upcoming_changes, yaml.load(safeForPublicChanges).upcoming_changes @@ -196,14 +191,3 @@ function updateStaticFile (json, filepath) { const jsonString = JSON.stringify(json, null, 2) updateFile(filepath, jsonString) } - -// run Ruby script to remove featureFlagged directives and other hidden members -function removeHiddenMembers (schemaPath, latestSchema) { - // have to write a temp file because the schema is too big to store in memory - const tempSchemaFilePath = `${schemaPath}-TEMP` - fs.writeFileSync(tempSchemaFilePath, latestSchema) - const remoteClean = execSync(`${removeHiddenMembersScript} ${tempSchemaFilePath}`).toString() - fs.unlinkSync(tempSchemaFilePath) - - return remoteClean -} diff --git a/script/graphql/utils/remove-hidden-schema-members.rb b/script/graphql/utils/remove-hidden-schema-members.rb deleted file mode 100755 index aee919f80ac3..000000000000 --- a/script/graphql/utils/remove-hidden-schema-members.rb +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env ruby - -require 'graphql' -require 'json' - -if ARGV.empty? - puts 'Must provide a GraphQL IDL filepath' - exit 1 -end - -# borrowed from graphql-docs/lib/graphql_docs/update_internal_developer/idl.rb -class Printer < GraphQL::Language::DocumentFromSchemaDefinition - def build_object_type_node(object_type) - apply_directives_to_node(object_type, super) - end - - def build_field_node(field) - apply_directives_to_node(field, super) - end - - def build_union_type_node(union_type) - apply_directives_to_node(union_type, super) - end - - def build_interface_type_node(interface_type) - apply_directives_to_node(interface_type, super) - end - - def build_enum_type_node(enum_type) - apply_directives_to_node(enum_type, super) - end - - def build_enum_value_node(enum_value) - apply_directives_to_node(enum_value, super) - end - - def build_scalar_type_node(scalar_type) - apply_directives_to_node(scalar_type, super) - end - - def build_argument_node(argument) - node = super - node = apply_directives_to_node(argument, node) - node = filter_possible_types_directive(argument, node) - node - end - - def build_input_object_node(input_object) - apply_directives_to_node(input_object, super) - end - - private - - def apply_directives_to_node(defn, node) - directives = defn.ast_node ? defn.ast_node.directives : [] - if directives.any? - node = node.merge(directives: directives) - end - node - end - - def filter_possible_types_directive(argument, node) - possible_types_directive = argument.ast_node.directives.find { |directive| directive.name == "possibleTypes" } - return node unless possible_types_directive - - concrete_types_argument = possible_types_directive.arguments.find { |argument| argument.name == "concreteTypes" } - filtered_concrete_types_value = concrete_types_argument.value.select { |type_name| warden.get_type(type_name) != nil } - filtered_concrete_types_argument = concrete_types_argument.merge(value: filtered_concrete_types_value) - - abstract_type_argument = possible_types_directive.arguments.find { |argument| argument.name == "abstractType" } - - new_possible_type_arguments = if abstract_type_argument.nil? || warden.get_type(abstract_type_argument.value).nil? - [filtered_concrete_types_argument] - else - [filtered_concrete_types_argument, abstract_type_argument] - end - - new_possible_types_directive = possible_types_directive.merge( - arguments: new_possible_type_arguments - ) - - new_directives_for_node = node.directives.map do |dir_node| - if dir_node.name == "possibleTypes" - new_possible_types_directive - else - dir_node - end - end - node.merge(directives: new_directives_for_node) - end -end - -def decode_idl(idl_str) - # Also remove feature-flagged things - schema = GraphQL::Schema.from_definition(idl_str.chomp.force_encoding(Encoding::UTF_8)) - # GraphQL-Ruby puts all types in `schema.orphan_types`, - # but that breaks the `reachable_types` test, - # so empty out the previous set of orphan types - schema.send(:own_orphan_types).clear - Printer.new(schema).document.to_query_string -end - -idl = ARGV[0] -idl_content = File.read(idl) - -clean_idl = decode_idl(idl_content) - -puts clean_idl