@graphql-inspector/diff-command 3.4.8-alpha-20230403113909-e09091f3 → 3.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.js → cjs/index.js} +33 -37
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +7 -11
- package/package.json +33 -12
- package/typings/index.d.ts +18 -0
- /package/{index.d.ts → typings/index.d.cts} +0 -0
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const logger = require('@graphql-inspector/logger');
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const commands_1 = require("@graphql-inspector/commands");
|
|
7
|
+
const core_1 = require("@graphql-inspector/core");
|
|
8
|
+
const logger_1 = require("@graphql-inspector/logger");
|
|
11
9
|
function handler(input) {
|
|
12
|
-
return
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
11
|
const onComplete = input.onComplete
|
|
14
12
|
? resolveCompletionHandler(input.onComplete)
|
|
15
13
|
: failOnBreakingChanges;
|
|
@@ -25,17 +23,17 @@ function handler(input) {
|
|
|
25
23
|
})
|
|
26
24
|
.filter(f => f)
|
|
27
25
|
: [];
|
|
28
|
-
const changes = yield
|
|
26
|
+
const changes = yield (0, core_1.diff)(input.oldSchema, input.newSchema, rules, {
|
|
29
27
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
30
28
|
});
|
|
31
29
|
if (changes.length === 0) {
|
|
32
|
-
|
|
30
|
+
logger_1.Logger.success('No changes detected');
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
const breakingChanges = changes.filter(change => change.criticality.level ===
|
|
37
|
-
const dangerousChanges = changes.filter(change => change.criticality.level ===
|
|
38
|
-
const nonBreakingChanges = changes.filter(change => change.criticality.level ===
|
|
33
|
+
logger_1.Logger.log(`\nDetected the following changes (${changes.length}) between schemas:\n`);
|
|
34
|
+
const breakingChanges = changes.filter(change => change.criticality.level === core_1.CriticalityLevel.Breaking);
|
|
35
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === core_1.CriticalityLevel.Dangerous);
|
|
36
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === core_1.CriticalityLevel.NonBreaking);
|
|
39
37
|
if (breakingChanges.length) {
|
|
40
38
|
reportBreakingChanges(breakingChanges);
|
|
41
39
|
}
|
|
@@ -48,7 +46,8 @@ function handler(input) {
|
|
|
48
46
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
|
|
49
|
+
exports.handler = handler;
|
|
50
|
+
exports.default = (0, commands_1.createCommand)(api => {
|
|
52
51
|
const { loaders } = api;
|
|
53
52
|
return {
|
|
54
53
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -82,14 +81,14 @@ const index = commands.createCommand(api => {
|
|
|
82
81
|
},
|
|
83
82
|
handler(args) {
|
|
84
83
|
var _a;
|
|
85
|
-
return
|
|
84
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
85
|
try {
|
|
87
86
|
const oldSchemaPointer = args.oldSchema;
|
|
88
87
|
const newSchemaPointer = args.newSchema;
|
|
89
88
|
const apolloFederation = args.federation || false;
|
|
90
89
|
const aws = args.aws || false;
|
|
91
90
|
const method = ((_a = args.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'POST';
|
|
92
|
-
const { headers, leftHeaders, rightHeaders, token } =
|
|
91
|
+
const { headers, leftHeaders, rightHeaders, token } = (0, commands_1.parseGlobalArgs)(args);
|
|
93
92
|
const oldSchemaHeaders = Object.assign(Object.assign({}, headers), leftHeaders);
|
|
94
93
|
const newSchemaHeaders = Object.assign(Object.assign({}, headers), rightHeaders);
|
|
95
94
|
const oldSchema = yield loaders.loadSchema(oldSchemaPointer, {
|
|
@@ -111,7 +110,7 @@ const index = commands.createCommand(api => {
|
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
112
|
catch (error) {
|
|
114
|
-
|
|
113
|
+
logger_1.Logger.error(error);
|
|
115
114
|
throw error;
|
|
116
115
|
}
|
|
117
116
|
});
|
|
@@ -132,35 +131,35 @@ function sortChanges(changes) {
|
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
133
|
function reportBreakingChanges(changes) {
|
|
135
|
-
const label =
|
|
134
|
+
const label = logger_1.symbols.error;
|
|
136
135
|
const sorted = sortChanges(changes);
|
|
137
136
|
sorted.forEach(change => {
|
|
138
|
-
|
|
137
|
+
logger_1.Logger.log(`${label} ${(0, logger_1.bolderize)(change.message)}`);
|
|
139
138
|
});
|
|
140
139
|
}
|
|
141
140
|
function reportDangerousChanges(changes) {
|
|
142
|
-
const label =
|
|
141
|
+
const label = logger_1.symbols.warning;
|
|
143
142
|
const sorted = sortChanges(changes);
|
|
144
143
|
sorted.forEach(change => {
|
|
145
|
-
|
|
144
|
+
logger_1.Logger.log(`${label} ${(0, logger_1.bolderize)(change.message)}`);
|
|
146
145
|
});
|
|
147
146
|
}
|
|
148
147
|
function reportNonBreakingChanges(changes) {
|
|
149
|
-
const label =
|
|
148
|
+
const label = logger_1.symbols.success;
|
|
150
149
|
const sorted = sortChanges(changes);
|
|
151
150
|
sorted.forEach(change => {
|
|
152
|
-
|
|
151
|
+
logger_1.Logger.log(`${label} ${(0, logger_1.bolderize)(change.message)}`);
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
function resolveRule(name) {
|
|
156
|
-
const filepath =
|
|
157
|
-
if (
|
|
155
|
+
const filepath = (0, commands_1.ensureAbsolute)(name);
|
|
156
|
+
if ((0, fs_1.existsSync)(filepath)) {
|
|
158
157
|
return require(filepath);
|
|
159
158
|
}
|
|
160
|
-
return
|
|
159
|
+
return core_1.DiffRule[name];
|
|
161
160
|
}
|
|
162
161
|
function resolveCompletionHandler(name) {
|
|
163
|
-
const filepath =
|
|
162
|
+
const filepath = (0, commands_1.ensureAbsolute)(name);
|
|
164
163
|
try {
|
|
165
164
|
require.resolve(filepath);
|
|
166
165
|
}
|
|
@@ -171,7 +170,7 @@ function resolveCompletionHandler(name) {
|
|
|
171
170
|
return (mod === null || mod === void 0 ? void 0 : mod.default) || mod;
|
|
172
171
|
}
|
|
173
172
|
function resolveUsageHandler(name) {
|
|
174
|
-
const filepath =
|
|
173
|
+
const filepath = (0, commands_1.ensureAbsolute)(name);
|
|
175
174
|
try {
|
|
176
175
|
require.resolve(filepath);
|
|
177
176
|
}
|
|
@@ -184,16 +183,13 @@ function resolveUsageHandler(name) {
|
|
|
184
183
|
function failOnBreakingChanges({ breakingChanges }) {
|
|
185
184
|
const breakingCount = breakingChanges.length;
|
|
186
185
|
if (breakingCount) {
|
|
187
|
-
|
|
186
|
+
logger_1.Logger.error(`Detected ${breakingCount} breaking change${breakingCount > 1 ? 's' : ''}`);
|
|
188
187
|
process.exit(1);
|
|
189
188
|
}
|
|
190
189
|
else {
|
|
191
|
-
|
|
190
|
+
logger_1.Logger.success('No breaking changes detected');
|
|
192
191
|
}
|
|
193
192
|
}
|
|
194
193
|
function isString(val) {
|
|
195
194
|
return typeof val === 'string';
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
exports.default = index;
|
|
199
|
-
exports.handler = handler;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { __awaiter } from
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { createCommand, parseGlobalArgs,
|
|
4
|
-
import {
|
|
5
|
-
import { Logger, symbols
|
|
6
|
-
|
|
7
|
-
function handler(input) {
|
|
3
|
+
import { createCommand, ensureAbsolute, parseGlobalArgs, } from '@graphql-inspector/commands';
|
|
4
|
+
import { CriticalityLevel, DiffRule, diff as diffSchema, } from '@graphql-inspector/core';
|
|
5
|
+
import { bolderize, Logger, symbols } from '@graphql-inspector/logger';
|
|
6
|
+
export function handler(input) {
|
|
8
7
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9
8
|
const onComplete = input.onComplete
|
|
10
9
|
? resolveCompletionHandler(input.onComplete)
|
|
@@ -21,7 +20,7 @@ function handler(input) {
|
|
|
21
20
|
})
|
|
22
21
|
.filter(f => f)
|
|
23
22
|
: [];
|
|
24
|
-
const changes = yield
|
|
23
|
+
const changes = yield diffSchema(input.oldSchema, input.newSchema, rules, {
|
|
25
24
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
26
25
|
});
|
|
27
26
|
if (changes.length === 0) {
|
|
@@ -44,7 +43,7 @@ function handler(input) {
|
|
|
44
43
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
export default createCommand(api => {
|
|
48
47
|
const { loaders } = api;
|
|
49
48
|
return {
|
|
50
49
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -190,6 +189,3 @@ function failOnBreakingChanges({ breakingChanges }) {
|
|
|
190
189
|
function isString(val) {
|
|
191
190
|
return typeof val === 'string';
|
|
192
191
|
}
|
|
193
|
-
|
|
194
|
-
export default index;
|
|
195
|
-
export { handler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/diff-command",
|
|
3
|
-
"version": "3.4.8
|
|
3
|
+
"version": "3.4.8",
|
|
4
4
|
"description": "Compare GraphQL Schemas",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"tslib": "^2.0.0",
|
|
11
|
-
"@graphql-inspector/commands": "3.4.
|
|
12
|
-
"@graphql-inspector/core": "4.
|
|
13
|
-
"@graphql-inspector/logger": "3.4.
|
|
11
|
+
"@graphql-inspector/commands": "3.4.5",
|
|
12
|
+
"@graphql-inspector/core": "4.0.3",
|
|
13
|
+
"@graphql-inspector/logger": "3.4.4"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -29,20 +29,41 @@
|
|
|
29
29
|
"url": "https://github.com/kamilkisiela"
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"main": "index.js",
|
|
33
|
-
"module": "index.
|
|
34
|
-
"typings": "index.d.ts",
|
|
32
|
+
"main": "cjs/index.js",
|
|
33
|
+
"module": "esm/index.js",
|
|
34
|
+
"typings": "typings/index.d.ts",
|
|
35
35
|
"typescript": {
|
|
36
|
-
"definition": "index.d.ts"
|
|
36
|
+
"definition": "typings/index.d.ts"
|
|
37
37
|
},
|
|
38
|
+
"type": "module",
|
|
38
39
|
"exports": {
|
|
39
40
|
".": {
|
|
40
|
-
"require":
|
|
41
|
-
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./typings/index.d.cts",
|
|
43
|
+
"default": "./cjs/index.js"
|
|
44
|
+
},
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./typings/index.d.ts",
|
|
47
|
+
"default": "./esm/index.js"
|
|
48
|
+
},
|
|
49
|
+
"default": {
|
|
50
|
+
"types": "./typings/index.d.ts",
|
|
51
|
+
"default": "./esm/index.js"
|
|
52
|
+
}
|
|
42
53
|
},
|
|
43
54
|
"./*": {
|
|
44
|
-
"require":
|
|
45
|
-
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./typings/*.d.cts",
|
|
57
|
+
"default": "./cjs/*.js"
|
|
58
|
+
},
|
|
59
|
+
"import": {
|
|
60
|
+
"types": "./typings/*.d.ts",
|
|
61
|
+
"default": "./esm/*.js"
|
|
62
|
+
},
|
|
63
|
+
"default": {
|
|
64
|
+
"types": "./typings/*.d.ts",
|
|
65
|
+
"default": "./esm/*.js"
|
|
66
|
+
}
|
|
46
67
|
},
|
|
47
68
|
"./package.json": "./package.json"
|
|
48
69
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { CommandFactory, GlobalArgs } from '@graphql-inspector/commands';
|
|
3
|
+
export { CommandFactory };
|
|
4
|
+
export declare function handler(input: {
|
|
5
|
+
oldSchema: GraphQLSchema;
|
|
6
|
+
newSchema: GraphQLSchema;
|
|
7
|
+
onComplete?: string;
|
|
8
|
+
onUsage?: string;
|
|
9
|
+
rules?: Array<string | number>;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
declare const _default: CommandFactory<{}, {
|
|
12
|
+
oldSchema: string;
|
|
13
|
+
newSchema: string;
|
|
14
|
+
rule?: (string | number)[] | undefined;
|
|
15
|
+
onComplete?: string | undefined;
|
|
16
|
+
onUsage?: string | undefined;
|
|
17
|
+
} & GlobalArgs>;
|
|
18
|
+
export default _default;
|
|
File without changes
|