Skip to content

Commit

Permalink
Bump dependencies (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
exogen authored Oct 7, 2022
1 parent c5d6712 commit bc5a708
Show file tree
Hide file tree
Showing 15 changed files with 3,245 additions and 4,306 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module.exports = {
extends: ['standard', 'prettier', 'prettier/standard'],
extends: ['standard', 'prettier'],
env: {
es6: true,
node: true,
jest: true
jest: true,
},
parserOptions: {
ecmaVersion: 2018
ecmaVersion: 2018,
},
plugins: ['prettier'],
rules: {
'prettier/prettier': [
'warn',
{
singleQuote: true,
semi: false
}
]
}
semi: false,
},
],
},
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

lint-staged
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
proseWrap: "always"
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
collectCoverageFrom: ['src/**']
collectCoverageFrom: ['src/**'],
}
48 changes: 22 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Brian Beck <[email protected]>",
"license": "MIT",
"engines": {
"node": ">=8.10.0"
"node": ">=14.0.0"
},
"files": [
"src",
Expand All @@ -19,19 +19,14 @@
"format": "npm run lint:fix || true",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prepare": "husky install",
"test": "npm run lint && npm run test:coverage",
"test:coverage": "jest --coverage",
"test:only": "jest"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
"eslint --fix"
]
},
"peerDependencies": {
Expand All @@ -40,26 +35,27 @@
"dependencies": {
"deep-diff": "^1.0.2",
"lodash.isplainobject": "^4.0.6",
"minimist": "^1.2.0",
"node-fetch": "^2.2.0",
"resolve-from": "^4.0.0"
"minimist": "^1.2.6",
"node-fetch": "^2.0.0",
"resolve-from": "^5.0.0"
},
"devDependencies": {
"coveralls": "^3.0.2",
"eslint": "^5.6.1",
"eslint-config-prettier": "^3.1.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"graphbrainz": "^8.1.0",
"coveralls": "^3.1.1",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-standard": "^5.0.0",
"graphbrainz": "^8.0.0",
"graphql": "^16.0.0",
"husky": "^1.1.0",
"jest": "^23.6.0",
"lint-staged": "^7.3.0",
"prettier": "^1.14.3",
"tempy": "^0.2.1"
"husky": "^8.0.1",
"jest": "^29.1.2",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"tempy": "^1.0.0"
}
}
30 changes: 15 additions & 15 deletions src/diffSchema.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
const diff = require('deep-diff')

function toNamedObject(arr, modifier = obj => obj) {
function toNamedObject(arr, modifier = (obj) => obj) {
if (!arr) {
return {}
}
Expand All @@ -11,7 +11,7 @@ function toNamedObject(arr, modifier = obj => obj) {
}, {})
}

function toNamedArray(obj, modifier = obj => obj) {
function toNamedArray(obj, modifier = (obj) => obj) {
if (!obj) {
return []
}
Expand All @@ -21,15 +21,15 @@ function toNamedArray(obj, modifier = obj => obj) {
}

function toDiffableSchema(schema) {
const types = toNamedObject(schema.__schema.types, type => {
const types = toNamedObject(schema.__schema.types, (type) => {
if (type.fields) {
type = Object.assign({}, type, {
fields: toNamedObject(type.fields)
fields: toNamedObject(type.fields),
})
}
if (type.enumValues) {
type = Object.assign({}, type, {
enumValues: toNamedObject(type.enumValues)
enumValues: toNamedObject(type.enumValues),
})
}
return type
Expand All @@ -40,21 +40,21 @@ function toDiffableSchema(schema) {
return Object.assign({}, schema, {
__schema: Object.assign({}, schema.__schema, {
types,
directives
})
directives,
}),
})
}

function fromDiffableSchema(schema) {
const types = toNamedArray(schema.__schema.types, type => {
const types = toNamedArray(schema.__schema.types, (type) => {
if (type.fields) {
type = Object.assign({}, type, {
fields: toNamedArray(type.fields)
fields: toNamedArray(type.fields),
})
}
if (type.enumValues) {
type = Object.assign({}, type, {
enumValues: toNamedArray(type.enumValues)
enumValues: toNamedArray(type.enumValues),
})
}
return type
Expand All @@ -65,8 +65,8 @@ function fromDiffableSchema(schema) {
return Object.assign({}, schema, {
__schema: Object.assign({}, schema.__schema, {
types,
directives
})
directives,
}),
})
}

Expand All @@ -80,19 +80,19 @@ function diffSchema(oldSchema, newSchema, options = {}) {
}, {})
const schema = fromDiffableSchema(diffSchema)
const newTypes = newDiffableSchema.__schema.types
schema.__schema.types = schema.__schema.types.map(type => {
schema.__schema.types = schema.__schema.types.map((type) => {
if (options.processTypeDiff) {
type = options.processTypeDiff(type)
}
type = Object.assign({}, newTypes[type.name], type)
if (type.fields) {
const newFields = newTypes[type.name].fields
type.fields = type.fields.map(field => newFields[field.name])
type.fields = type.fields.map((field) => newFields[field.name])
}
if (type.enumValues) {
const newEnumValues = newTypes[type.name].enumValues
type.enumValues = type.enumValues.map(
enumValue => newEnumValues[enumValue.name]
(enumValue) => newEnumValues[enumValue.name]
)
}
return type
Expand Down
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const updateSchema = require('./updateSchema')
const diffSchema = require('./diffSchema')

function safeExit(code) {
process.on('exit', function() {
process.on('exit', function () {
process.exit(code)
})
}
Expand Down Expand Up @@ -66,26 +66,26 @@ function run(
}
}
const schemaPath = args._[0]
const headers = [].concat(args['header'] || []).reduce((obj, header) => {
const headers = [].concat(args.header || []).reduce((obj, header) => {
const [key, ...value] = String(header).split('=')
obj[key] = value.join('=')
return obj
}, {})
const loadOptions = { headers }
loadSchemaJSON(schemaPath, loadOptions).then(schema => {
loadSchemaJSON(schemaPath, loadOptions).then((schema) => {
const options = {
title: args.title,
skipTitle: false,
prologue: args.prologue,
epilogue: args.epilogue,
skipTableOfContents: args['toc'] === false,
headingLevel: args['heading-level']
skipTableOfContents: args.toc === false,
headingLevel: args['heading-level'],
}
if (options.title === false) {
options.title = ''
options.skipTitle = true
} else if (Array.isArray(options.title)) {
options.title.forEach(value => {
options.title.forEach((value) => {
if (typeof value === 'string') {
options.title = value
} else if (value === false) {
Expand All @@ -101,7 +101,7 @@ function run(
safeExit(0)
}
})
.catch(err => {
.catch((err) => {
console.error(err)
if (exit) {
safeExit(1)
Expand All @@ -128,7 +128,7 @@ module.exports = {
schemaToJSON,
renderSchema,
updateSchema,
diffSchema
diffSchema,
}

if (require.main === module) {
Expand Down
20 changes: 9 additions & 11 deletions src/loadSchemaJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ const DEFAULT_GRAPHQL = graphql

function readFile(filename) {
return new Promise((resolve, reject) => {
fs.readFile(
filename,
'utf8',
(err, data) => (err ? reject(err) : resolve(data))
fs.readFile(filename, 'utf8', (err, data) =>
err ? reject(err) : resolve(data)
)
})
}
Expand All @@ -21,7 +19,7 @@ function schemaToJSON(schema, options) {
options = options || {}
const graphql = options.graphql || DEFAULT_GRAPHQL
const source = graphql.getIntrospectionQuery()
return graphql.graphql({ schema, source }).then(result => {
return graphql.graphql({ schema, source }).then((result) => {
return result.data
})
}
Expand All @@ -34,18 +32,18 @@ function fetchSchemaJSON(url, options) {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...options.headers
...options.headers,
},
body: JSON.stringify({ query: graphql.getIntrospectionQuery() })
body: JSON.stringify({ query: graphql.getIntrospectionQuery() }),
})
.then(res => res.json())
.then(result => result.data)
.then((res) => res.json())
.then((result) => result.data)
}

function parseSchemaGraphQL(filename, options) {
options = options || {}
const graphql = options.graphql || DEFAULT_GRAPHQL
return readFile(filename).then(data => graphql.buildSchema(data))
return readFile(filename).then((data) => graphql.buildSchema(data))
}

async function requireSchema(schemaPath) {
Expand Down Expand Up @@ -88,7 +86,7 @@ async function requireSchema(schemaPath) {
}
throw new Error(
`Schema not found in ${schemaModule} - check that you are exporting ` +
`an instance of GraphQLSchema or the result of an introspection query`
'an instance of GraphQLSchema or the result of an introspection query'
)
}

Expand Down
Loading

0 comments on commit bc5a708

Please sign in to comment.