mirror of
				https://gitea.com/actions/setup-node.git
				synced 2025-10-29 15:52:42 +08:00 
			
		
		
		
	new toolkit and scoped registries
This commit is contained in:
		
							
								
								
									
										16
									
								
								node_modules/@octokit/graphql/lib/error.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								node_modules/@octokit/graphql/lib/error.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
module.exports = class GraphqlError extends Error {
 | 
			
		||||
  constructor (request, response) {
 | 
			
		||||
    const message = response.data.errors[0].message
 | 
			
		||||
    super(message)
 | 
			
		||||
 | 
			
		||||
    Object.assign(this, response.data)
 | 
			
		||||
    this.name = 'GraphqlError'
 | 
			
		||||
    this.request = request
 | 
			
		||||
 | 
			
		||||
    // Maintains proper stack trace (only available on V8)
 | 
			
		||||
    /* istanbul ignore next */
 | 
			
		||||
    if (Error.captureStackTrace) {
 | 
			
		||||
      Error.captureStackTrace(this, this.constructor)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								node_modules/@octokit/graphql/lib/graphql.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								node_modules/@octokit/graphql/lib/graphql.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
module.exports = graphql
 | 
			
		||||
 | 
			
		||||
const GraphqlError = require('./error')
 | 
			
		||||
 | 
			
		||||
const NON_VARIABLE_OPTIONS = ['method', 'baseUrl', 'url', 'headers', 'request', 'query']
 | 
			
		||||
 | 
			
		||||
function graphql (request, query, options) {
 | 
			
		||||
  if (typeof query === 'string') {
 | 
			
		||||
    options = Object.assign({ query }, options)
 | 
			
		||||
  } else {
 | 
			
		||||
    options = query
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const requestOptions = Object.keys(options).reduce((result, key) => {
 | 
			
		||||
    if (NON_VARIABLE_OPTIONS.includes(key)) {
 | 
			
		||||
      result[key] = options[key]
 | 
			
		||||
      return result
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!result.variables) {
 | 
			
		||||
      result.variables = {}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    result.variables[key] = options[key]
 | 
			
		||||
    return result
 | 
			
		||||
  }, {})
 | 
			
		||||
 | 
			
		||||
  return request(requestOptions)
 | 
			
		||||
    .then(response => {
 | 
			
		||||
      if (response.data.errors) {
 | 
			
		||||
        throw new GraphqlError(requestOptions, response)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return response.data.data
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								node_modules/@octokit/graphql/lib/with-defaults.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								node_modules/@octokit/graphql/lib/with-defaults.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
module.exports = withDefaults
 | 
			
		||||
 | 
			
		||||
const graphql = require('./graphql')
 | 
			
		||||
 | 
			
		||||
function withDefaults (request, newDefaults) {
 | 
			
		||||
  const newRequest = request.defaults(newDefaults)
 | 
			
		||||
  const newApi = function (query, options) {
 | 
			
		||||
    return graphql(newRequest, query, options)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  newApi.defaults = withDefaults.bind(null, newRequest)
 | 
			
		||||
  return newApi
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user