Remove gemfile and ruby code (#19910)
This commit is contained in:
5
Gemfile
5
Gemfile
@@ -1,5 +0,0 @@
|
|||||||
source 'http://rubygems.org'
|
|
||||||
# ruby '2.4'
|
|
||||||
|
|
||||||
gem 'graphql', '1.10.6'
|
|
||||||
gem 'graphql-schema_comparator', '~> 1.0.0'
|
|
||||||
20
Gemfile.lock
20
Gemfile.lock
@@ -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
|
|
||||||
@@ -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/process-upcoming-changes.js`](graphql/utils/process-upcoming-changes.js)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
### [`graphql/utils/remove-hidden-schema-members.rb`](graphql/utils/remove-hidden-schema-members.rb)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ try {
|
|||||||
process.exit(1)
|
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 versionsToBuild = Object.keys(allVersions)
|
||||||
|
|
||||||
const currentLanguage = 'en'
|
const currentLanguage = 'en'
|
||||||
@@ -81,9 +77,8 @@ async function main () {
|
|||||||
const schemaPath = getDataFilepath('schemas', graphqlVersion)
|
const schemaPath = getDataFilepath('schemas', graphqlVersion)
|
||||||
const previousSchemaString = fs.readFileSync(schemaPath, 'utf8')
|
const previousSchemaString = fs.readFileSync(schemaPath, 'utf8')
|
||||||
const latestSchema = await getRemoteRawContent(schemaPath, graphqlVersion)
|
const latestSchema = await getRemoteRawContent(schemaPath, graphqlVersion)
|
||||||
const safeForPublicSchema = removeHiddenMembers(schemaPath, latestSchema)
|
updateFile(schemaPath, latestSchema)
|
||||||
updateFile(schemaPath, safeForPublicSchema)
|
const schemaJsonPerVersion = await processSchemas(latestSchema, safeForPublicPreviews)
|
||||||
const schemaJsonPerVersion = await processSchemas(safeForPublicSchema, safeForPublicPreviews)
|
|
||||||
updateStaticFile(schemaJsonPerVersion, path.join(graphqlStaticDir, `schema-${graphqlVersion}.json`))
|
updateStaticFile(schemaJsonPerVersion, path.join(graphqlStaticDir, `schema-${graphqlVersion}.json`))
|
||||||
|
|
||||||
// Add some version specific data to the context
|
// 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
|
// The Changelog is only build for free-pro-team@latest
|
||||||
const changelogEntry = await createChangelogEntry(
|
const changelogEntry = await createChangelogEntry(
|
||||||
previousSchemaString,
|
previousSchemaString,
|
||||||
safeForPublicSchema,
|
latestSchema,
|
||||||
safeForPublicPreviews,
|
safeForPublicPreviews,
|
||||||
previousUpcomingChanges.upcoming_changes,
|
previousUpcomingChanges.upcoming_changes,
|
||||||
yaml.load(safeForPublicChanges).upcoming_changes
|
yaml.load(safeForPublicChanges).upcoming_changes
|
||||||
@@ -196,14 +191,3 @@ function updateStaticFile (json, filepath) {
|
|||||||
const jsonString = JSON.stringify(json, null, 2)
|
const jsonString = JSON.stringify(json, null, 2)
|
||||||
updateFile(filepath, jsonString)
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user