@graphql-inspector/diff-command 3.3.0 → 3.4.0
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 +9 -11
- package/index.mjs +9 -11
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -10,9 +10,7 @@ const fs = require('fs');
|
|
|
10
10
|
|
|
11
11
|
function handler(input) {
|
|
12
12
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
const onComplete = input.onComplete
|
|
14
|
-
? resolveCompletionHandler(input.onComplete)
|
|
15
|
-
: failOnBreakingChanges;
|
|
13
|
+
const onComplete = input.onComplete ? resolveCompletionHandler(input.onComplete) : failOnBreakingChanges;
|
|
16
14
|
const rules = input.rules
|
|
17
15
|
? input.rules
|
|
18
16
|
.filter(isString)
|
|
@@ -23,7 +21,7 @@ function handler(input) {
|
|
|
23
21
|
}
|
|
24
22
|
return rule;
|
|
25
23
|
})
|
|
26
|
-
.filter(
|
|
24
|
+
.filter(f => f)
|
|
27
25
|
: [];
|
|
28
26
|
const changes = yield core.diff(input.oldSchema, input.newSchema, rules, {
|
|
29
27
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
@@ -33,9 +31,9 @@ function handler(input) {
|
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
33
|
logger.Logger.log(`\nDetected the following changes (${changes.length}) between schemas:\n`);
|
|
36
|
-
const breakingChanges = changes.filter(
|
|
37
|
-
const dangerousChanges = changes.filter(
|
|
38
|
-
const nonBreakingChanges = changes.filter(
|
|
34
|
+
const breakingChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.Breaking);
|
|
35
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.Dangerous);
|
|
36
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.NonBreaking);
|
|
39
37
|
if (breakingChanges.length) {
|
|
40
38
|
reportBreakingChanges(breakingChanges);
|
|
41
39
|
}
|
|
@@ -48,7 +46,7 @@ function handler(input) {
|
|
|
48
46
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
const index = commands.createCommand(
|
|
49
|
+
const index = commands.createCommand(api => {
|
|
52
50
|
const { loaders } = api;
|
|
53
51
|
return {
|
|
54
52
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -134,21 +132,21 @@ function sortChanges(changes) {
|
|
|
134
132
|
function reportBreakingChanges(changes) {
|
|
135
133
|
const label = logger.symbols.error;
|
|
136
134
|
const sorted = sortChanges(changes);
|
|
137
|
-
sorted.forEach(
|
|
135
|
+
sorted.forEach(change => {
|
|
138
136
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
139
137
|
});
|
|
140
138
|
}
|
|
141
139
|
function reportDangerousChanges(changes) {
|
|
142
140
|
const label = logger.symbols.warning;
|
|
143
141
|
const sorted = sortChanges(changes);
|
|
144
|
-
sorted.forEach(
|
|
142
|
+
sorted.forEach(change => {
|
|
145
143
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
146
144
|
});
|
|
147
145
|
}
|
|
148
146
|
function reportNonBreakingChanges(changes) {
|
|
149
147
|
const label = logger.symbols.success;
|
|
150
148
|
const sorted = sortChanges(changes);
|
|
151
|
-
sorted.forEach(
|
|
149
|
+
sorted.forEach(change => {
|
|
152
150
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
153
151
|
});
|
|
154
152
|
}
|
package/index.mjs
CHANGED
|
@@ -6,9 +6,7 @@ import { existsSync } from 'fs';
|
|
|
6
6
|
|
|
7
7
|
function handler(input) {
|
|
8
8
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
const onComplete = input.onComplete
|
|
10
|
-
? resolveCompletionHandler(input.onComplete)
|
|
11
|
-
: failOnBreakingChanges;
|
|
9
|
+
const onComplete = input.onComplete ? resolveCompletionHandler(input.onComplete) : failOnBreakingChanges;
|
|
12
10
|
const rules = input.rules
|
|
13
11
|
? input.rules
|
|
14
12
|
.filter(isString)
|
|
@@ -19,7 +17,7 @@ function handler(input) {
|
|
|
19
17
|
}
|
|
20
18
|
return rule;
|
|
21
19
|
})
|
|
22
|
-
.filter(
|
|
20
|
+
.filter(f => f)
|
|
23
21
|
: [];
|
|
24
22
|
const changes = yield diff(input.oldSchema, input.newSchema, rules, {
|
|
25
23
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
@@ -29,9 +27,9 @@ function handler(input) {
|
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
29
|
Logger.log(`\nDetected the following changes (${changes.length}) between schemas:\n`);
|
|
32
|
-
const breakingChanges = changes.filter(
|
|
33
|
-
const dangerousChanges = changes.filter(
|
|
34
|
-
const nonBreakingChanges = changes.filter(
|
|
30
|
+
const breakingChanges = changes.filter(change => change.criticality.level === CriticalityLevel.Breaking);
|
|
31
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === CriticalityLevel.Dangerous);
|
|
32
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === CriticalityLevel.NonBreaking);
|
|
35
33
|
if (breakingChanges.length) {
|
|
36
34
|
reportBreakingChanges(breakingChanges);
|
|
37
35
|
}
|
|
@@ -44,7 +42,7 @@ function handler(input) {
|
|
|
44
42
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
45
43
|
});
|
|
46
44
|
}
|
|
47
|
-
const index = createCommand(
|
|
45
|
+
const index = createCommand(api => {
|
|
48
46
|
const { loaders } = api;
|
|
49
47
|
return {
|
|
50
48
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -130,21 +128,21 @@ function sortChanges(changes) {
|
|
|
130
128
|
function reportBreakingChanges(changes) {
|
|
131
129
|
const label = symbols.error;
|
|
132
130
|
const sorted = sortChanges(changes);
|
|
133
|
-
sorted.forEach(
|
|
131
|
+
sorted.forEach(change => {
|
|
134
132
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
135
133
|
});
|
|
136
134
|
}
|
|
137
135
|
function reportDangerousChanges(changes) {
|
|
138
136
|
const label = symbols.warning;
|
|
139
137
|
const sorted = sortChanges(changes);
|
|
140
|
-
sorted.forEach(
|
|
138
|
+
sorted.forEach(change => {
|
|
141
139
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
142
|
function reportNonBreakingChanges(changes) {
|
|
145
143
|
const label = symbols.success;
|
|
146
144
|
const sorted = sortChanges(changes);
|
|
147
|
-
sorted.forEach(
|
|
145
|
+
sorted.forEach(change => {
|
|
148
146
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
149
147
|
});
|
|
150
148
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/diff-command",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Compare GraphQL Schemas",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-inspector/commands": "3.
|
|
11
|
-
"@graphql-inspector/core": "3.
|
|
12
|
-
"@graphql-inspector/logger": "3.
|
|
10
|
+
"@graphql-inspector/commands": "3.4.0",
|
|
11
|
+
"@graphql-inspector/core": "3.4.0",
|
|
12
|
+
"@graphql-inspector/logger": "3.4.0",
|
|
13
13
|
"tslib": "^2.0.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|