@graphql-inspector/diff-command 3.3.0 → 3.4.1-alpha-20230111095532-bd016dc8
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 +10 -10
- package/index.mjs +10 -10
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const tslib = require('tslib');
|
|
6
|
+
const fs = require('fs');
|
|
6
7
|
const commands = require('@graphql-inspector/commands');
|
|
7
8
|
const core = require('@graphql-inspector/core');
|
|
8
9
|
const logger = require('@graphql-inspector/logger');
|
|
9
|
-
const fs = require('fs');
|
|
10
10
|
|
|
11
11
|
function handler(input) {
|
|
12
12
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,11 +19,11 @@ function handler(input) {
|
|
|
19
19
|
.map((name) => {
|
|
20
20
|
const rule = resolveRule(name);
|
|
21
21
|
if (!rule) {
|
|
22
|
-
throw new Error(
|
|
22
|
+
throw new Error(`Rule '${name}' does not exist!\n`);
|
|
23
23
|
}
|
|
24
24
|
return rule;
|
|
25
25
|
})
|
|
26
|
-
.filter(
|
|
26
|
+
.filter(f => f)
|
|
27
27
|
: [];
|
|
28
28
|
const changes = yield core.diff(input.oldSchema, input.newSchema, rules, {
|
|
29
29
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
@@ -33,9 +33,9 @@ function handler(input) {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
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(
|
|
36
|
+
const breakingChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.Breaking);
|
|
37
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.Dangerous);
|
|
38
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.NonBreaking);
|
|
39
39
|
if (breakingChanges.length) {
|
|
40
40
|
reportBreakingChanges(breakingChanges);
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ function handler(input) {
|
|
|
48
48
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
const index = commands.createCommand(
|
|
51
|
+
const index = commands.createCommand(api => {
|
|
52
52
|
const { loaders } = api;
|
|
53
53
|
return {
|
|
54
54
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -134,21 +134,21 @@ function sortChanges(changes) {
|
|
|
134
134
|
function reportBreakingChanges(changes) {
|
|
135
135
|
const label = logger.symbols.error;
|
|
136
136
|
const sorted = sortChanges(changes);
|
|
137
|
-
sorted.forEach(
|
|
137
|
+
sorted.forEach(change => {
|
|
138
138
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
function reportDangerousChanges(changes) {
|
|
142
142
|
const label = logger.symbols.warning;
|
|
143
143
|
const sorted = sortChanges(changes);
|
|
144
|
-
sorted.forEach(
|
|
144
|
+
sorted.forEach(change => {
|
|
145
145
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
function reportNonBreakingChanges(changes) {
|
|
149
149
|
const label = logger.symbols.success;
|
|
150
150
|
const sorted = sortChanges(changes);
|
|
151
|
-
sorted.forEach(
|
|
151
|
+
sorted.forEach(change => {
|
|
152
152
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
153
153
|
});
|
|
154
154
|
}
|
package/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
2
3
|
import { createCommand, parseGlobalArgs, ensureAbsolute } from '@graphql-inspector/commands';
|
|
3
4
|
import { diff, CriticalityLevel, DiffRule } from '@graphql-inspector/core';
|
|
4
5
|
import { Logger, symbols, bolderize } from '@graphql-inspector/logger';
|
|
5
|
-
import { existsSync } from 'fs';
|
|
6
6
|
|
|
7
7
|
function handler(input) {
|
|
8
8
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -15,11 +15,11 @@ function handler(input) {
|
|
|
15
15
|
.map((name) => {
|
|
16
16
|
const rule = resolveRule(name);
|
|
17
17
|
if (!rule) {
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error(`Rule '${name}' does not exist!\n`);
|
|
19
19
|
}
|
|
20
20
|
return rule;
|
|
21
21
|
})
|
|
22
|
-
.filter(
|
|
22
|
+
.filter(f => f)
|
|
23
23
|
: [];
|
|
24
24
|
const changes = yield diff(input.oldSchema, input.newSchema, rules, {
|
|
25
25
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
@@ -29,9 +29,9 @@ function handler(input) {
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
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(
|
|
32
|
+
const breakingChanges = changes.filter(change => change.criticality.level === CriticalityLevel.Breaking);
|
|
33
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === CriticalityLevel.Dangerous);
|
|
34
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === CriticalityLevel.NonBreaking);
|
|
35
35
|
if (breakingChanges.length) {
|
|
36
36
|
reportBreakingChanges(breakingChanges);
|
|
37
37
|
}
|
|
@@ -44,7 +44,7 @@ function handler(input) {
|
|
|
44
44
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
const index = createCommand(
|
|
47
|
+
const index = createCommand(api => {
|
|
48
48
|
const { loaders } = api;
|
|
49
49
|
return {
|
|
50
50
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -130,21 +130,21 @@ function sortChanges(changes) {
|
|
|
130
130
|
function reportBreakingChanges(changes) {
|
|
131
131
|
const label = symbols.error;
|
|
132
132
|
const sorted = sortChanges(changes);
|
|
133
|
-
sorted.forEach(
|
|
133
|
+
sorted.forEach(change => {
|
|
134
134
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
function reportDangerousChanges(changes) {
|
|
138
138
|
const label = symbols.warning;
|
|
139
139
|
const sorted = sortChanges(changes);
|
|
140
|
-
sorted.forEach(
|
|
140
|
+
sorted.forEach(change => {
|
|
141
141
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
function reportNonBreakingChanges(changes) {
|
|
145
145
|
const label = symbols.success;
|
|
146
146
|
const sorted = sortChanges(changes);
|
|
147
|
-
sorted.forEach(
|
|
147
|
+
sorted.forEach(change => {
|
|
148
148
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
149
149
|
});
|
|
150
150
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/diff-command",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1-alpha-20230111095532-bd016dc8",
|
|
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.1-alpha-20230111095532-bd016dc8",
|
|
11
|
+
"@graphql-inspector/core": "3.4.1-alpha-20230111095532-bd016dc8",
|
|
12
|
+
"@graphql-inspector/logger": "3.4.1-alpha-20230111095532-bd016dc8",
|
|
13
13
|
"tslib": "^2.0.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|