11#!/usr/bin/env node
22
3- import meow from ' meow' ;
4- import chalk from ' chalk' ;
5- import { createHtmlOutput } from ' ./html' ;
6- import { getDiff , Headers } from ' ./diff' ;
3+ import meow from " meow" ;
4+ import chalk from " chalk" ;
5+ import { createHtmlOutput } from " ./html" ;
6+ import { getDiff , Headers } from " ./diff" ;
77
88const cli = meow (
99 `
@@ -29,46 +29,46 @@ const cli = meow(
2929 {
3030 flags : {
3131 "fail-on-dangerous-changes" : {
32- type : "boolean"
32+ type : "boolean" ,
3333 } ,
3434 "fail-on-breaking-changes" : {
35- type : "boolean"
35+ type : "boolean" ,
3636 } ,
3737 "fail-on-all-changes" : {
38- type : "boolean"
38+ type : "boolean" ,
3939 } ,
4040 "use-colors" : {
41- type : "boolean"
41+ type : "boolean" ,
4242 } ,
4343 "create-html-output" : {
44- type : "boolean"
44+ type : "boolean" ,
4545 } ,
4646 "html-output-directory" : {
4747 type : "string" ,
48- default : "schemaDiff"
48+ default : "schemaDiff" ,
4949 } ,
5050 header : {
5151 type : "string" ,
52- alias : "H"
52+ alias : "H" ,
5353 } ,
5454 "left-schema-header" : {
55- type : "string"
55+ type : "string" ,
5656 } ,
5757 "right-schema-header" : {
58- type : "string"
58+ type : "string" ,
5959 } ,
6060 "sort-schema" : {
6161 type : "boolean" ,
62- alias : "s"
63- }
64- }
62+ alias : "s" ,
63+ } ,
64+ } ,
6565 }
6666) ;
6767
6868function parseHeaders ( headerInput ?: string | string [ ] ) : Headers | undefined {
6969 let headers : string [ ] [ ] ;
7070 const parseHeader = ( header : string ) : string [ ] =>
71- header . split ( ':' ) . map ( ( val : string ) => val . trim ( ) ) ;
71+ header . split ( ":" ) . map ( ( val : string ) => val . trim ( ) ) ;
7272
7373 if ( ! headerInput ) return ;
7474
@@ -81,7 +81,7 @@ function parseHeaders(headerInput?: string | string[]): Headers | undefined {
8181 return headers . reduce (
8282 ( result , [ key , value ] ) => ( {
8383 ...result ,
84- ...( key && value && { [ key ] : value } )
84+ ...( key && value && { [ key ] : value } ) ,
8585 } ) ,
8686 { }
8787 ) ;
@@ -91,7 +91,7 @@ const [leftSchemaLocation, rightSchemaLocation]: string[] = cli.input;
9191const {
9292 header ,
9393 leftSchemaHeader ,
94- rightSchemaHeader
94+ rightSchemaHeader ,
9595} : {
9696 header ?: string | string [ ] ;
9797 leftSchemaHeader ?: string | string [ ] ;
@@ -100,10 +100,10 @@ const {
100100
101101if ( ! leftSchemaLocation || ! rightSchemaLocation ) {
102102 console . error (
103- chalk . red ( ' ERROR: Schema locations missing!\n\n' ) ,
103+ chalk . red ( " ERROR: Schema locations missing!\n\n" ) ,
104104 chalk . gray (
105- ' Usage\n' +
106- ' $ graphql-schema-diff <leftSchemaLocation> <rightSchemaLocation>'
105+ " Usage\n" +
106+ " $ graphql-schema-diff <leftSchemaLocation> <rightSchemaLocation>"
107107 )
108108 ) ;
109109 process . exit ( 1 ) ;
@@ -112,16 +112,16 @@ if (!leftSchemaLocation || !rightSchemaLocation) {
112112getDiff ( leftSchemaLocation , rightSchemaLocation , {
113113 headers : parseHeaders ( header ) ,
114114 leftSchema : {
115- headers : parseHeaders ( leftSchemaHeader )
115+ headers : parseHeaders ( leftSchemaHeader ) ,
116116 } ,
117117 rightSchema : {
118- headers : parseHeaders ( rightSchemaHeader )
118+ headers : parseHeaders ( rightSchemaHeader ) ,
119119 } ,
120- sortSchema : cli . flags . sortSchema as boolean
120+ sortSchema : cli . flags . sortSchema as boolean ,
121121} )
122- . then ( async result => {
122+ . then ( async ( result ) => {
123123 if ( result === undefined ) {
124- console . warn ( chalk . green ( ' ✔ No changes' ) ) ;
124+ console . warn ( chalk . green ( " ✔ No changes" ) ) ;
125125 return ;
126126 }
127127
@@ -135,10 +135,10 @@ getDiff(leftSchemaLocation, rightSchemaLocation, {
135135 }
136136
137137 if ( hasDangerousChanges ) {
138- console . warn ( chalk . yellow . bold . underline ( ' Dangerous changes' ) ) ;
138+ console . warn ( chalk . yellow . bold . underline ( " Dangerous changes" ) ) ;
139139
140140 for ( const change of result . dangerousChanges ) {
141- console . warn ( chalk . yellow ( ' ⚠ ' + change . description ) ) ;
141+ console . warn ( chalk . yellow ( " ⚠ " + change . description ) ) ;
142142 }
143143 }
144144
@@ -147,16 +147,16 @@ getDiff(leftSchemaLocation, rightSchemaLocation, {
147147 }
148148
149149 if ( hasBreakingChanges ) {
150- console . warn ( chalk . red . bold . underline ( ' BREAKING CHANGES' ) ) ;
150+ console . warn ( chalk . red . bold . underline ( " BREAKING CHANGES" ) ) ;
151151
152152 for ( const change of result . breakingChanges ) {
153- console . warn ( chalk . red ( ' ✖ ' + change . description ) ) ;
153+ console . warn ( chalk . red ( " ✖ " + change . description ) ) ;
154154 }
155155 }
156156
157157 if ( cli . flags . createHtmlOutput ) {
158158 await createHtmlOutput ( result . diffNoColor , {
159- outputDirectory : cli . flags . htmlOutputDirectory as string | undefined
159+ outputDirectory : cli . flags . htmlOutputDirectory as string | undefined ,
160160 } ) ;
161161 }
162162
@@ -169,7 +169,7 @@ getDiff(leftSchemaLocation, rightSchemaLocation, {
169169 return ;
170170 }
171171 } )
172- . catch ( err => {
172+ . catch ( ( err ) => {
173173 console . error ( chalk . red ( `\nERROR: ${ err . message } ` ) ) ;
174174 process . exit ( 1 ) ;
175175 } ) ;
0 commit comments