@graphql-inspector/cli 3.4.16 → 3.4.17-alpha-20230425145409-b74fa0f2
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/cjs/commands/coverage/src/index.js +33 -9
- package/cjs/core/src/coverage/index.js +16 -0
- package/cjs/logger/src/index.js +25 -0
- package/esm/commands/coverage/src/index.js +33 -9
- package/esm/core/src/coverage/index.js +16 -0
- package/esm/logger/src/index.js +25 -0
- package/package.json +8 -8
- package/typings/core/src/coverage/index.d.cts +3 -0
- package/typings/core/src/coverage/index.d.ts +3 -0
- package/typings/logger/src/index.d.cts +4 -0
- package/typings/logger/src/index.d.ts +4 -0
|
@@ -111,15 +111,39 @@ function renderCoverage(coverage) {
|
|
|
111
111
|
logger_1.Logger.log(logger_1.chalk.grey('}\n'));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
const logStatsResult = [
|
|
115
|
+
{
|
|
116
|
+
method: 'Types covered',
|
|
117
|
+
result: `${coverage.stats.numTypes > 0
|
|
118
|
+
? ((coverage.stats.numTypesCovered / coverage.stats.numTypes) * 100).toFixed(1)
|
|
119
|
+
: 'N/A'}%`,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
method: 'Types covered fully',
|
|
123
|
+
result: `${coverage.stats.numTypes > 0
|
|
124
|
+
? ((coverage.stats.numTypesCoveredFully / coverage.stats.numTypes) * 100).toFixed(1)
|
|
125
|
+
: 'N/A'}%`,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
method: 'Fields covered',
|
|
129
|
+
result: `${coverage.stats.numFields > 0
|
|
130
|
+
? ((coverage.stats.numFiledsCovered / coverage.stats.numFields) * 100).toFixed(1)
|
|
131
|
+
: 'N/A'}%`,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
method: 'Total Queries',
|
|
135
|
+
result: String(coverage.stats.numQueries > 0 ? coverage.stats.numQueries : '0'),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
method: 'Total Mutations',
|
|
139
|
+
result: String(coverage.stats.numMutations > 0 ? coverage.stats.numMutations : '0'),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
method: 'Total Subscriptions',
|
|
143
|
+
result: String(coverage.stats.numSubscriptions > 0 ? coverage.stats.numSubscriptions : '0'),
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
logger_1.Logger.table(logStatsResult);
|
|
123
147
|
logger_1.Logger.log(``);
|
|
124
148
|
}
|
|
125
149
|
function indent(line, space) {
|
|
@@ -14,6 +14,9 @@ function coverage(schema, sources) {
|
|
|
14
14
|
numTypesCovered: 0,
|
|
15
15
|
numFields: 0,
|
|
16
16
|
numFiledsCovered: 0,
|
|
17
|
+
numQueries: 0,
|
|
18
|
+
numMutations: 0,
|
|
19
|
+
numSubscriptions: 0,
|
|
17
20
|
},
|
|
18
21
|
};
|
|
19
22
|
const typeMap = schema.getTypeMap();
|
|
@@ -62,6 +65,19 @@ function coverage(schema, sources) {
|
|
|
62
65
|
type,
|
|
63
66
|
children: {},
|
|
64
67
|
};
|
|
68
|
+
if ((0, graphql_1.isObjectType)(type) || (0, graphql_1.isInterfaceType)(type)) {
|
|
69
|
+
switch (type.name) {
|
|
70
|
+
case 'Query':
|
|
71
|
+
coverage.stats.numQueries++;
|
|
72
|
+
break;
|
|
73
|
+
case 'Mutation':
|
|
74
|
+
coverage.stats.numMutations++;
|
|
75
|
+
break;
|
|
76
|
+
case 'Subscription':
|
|
77
|
+
coverage.stats.numSubscriptions++;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
65
81
|
const fieldMap = type.getFields();
|
|
66
82
|
for (const fieldname in fieldMap) {
|
|
67
83
|
const field = fieldMap[fieldname];
|
package/cjs/logger/src/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unmockLogger = exports.mockLogger = exports.Logger = exports.bolderize = exports.chalk = exports.symbols = exports.figures = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const node_console_1 = require("node:console");
|
|
6
|
+
const node_stream_1 = require("node:stream");
|
|
5
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
8
|
exports.chalk = chalk_1.default;
|
|
7
9
|
const env = tslib_1.__importStar(require("std-env"));
|
|
@@ -26,6 +28,9 @@ exports.Logger = {
|
|
|
26
28
|
log(msg) {
|
|
27
29
|
emit('log', msg);
|
|
28
30
|
},
|
|
31
|
+
table(input) {
|
|
32
|
+
table(input);
|
|
33
|
+
},
|
|
29
34
|
info(msg) {
|
|
30
35
|
emit('info', msg);
|
|
31
36
|
},
|
|
@@ -67,6 +72,26 @@ function emit(type, msg) {
|
|
|
67
72
|
console.log(msg);
|
|
68
73
|
}
|
|
69
74
|
}
|
|
75
|
+
function table(input) {
|
|
76
|
+
const ts = new node_stream_1.Transform({
|
|
77
|
+
transform(chunk, _enc, cb) {
|
|
78
|
+
cb(null, chunk);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const logger = new node_console_1.Console({ stdout: ts });
|
|
82
|
+
logger.table(input);
|
|
83
|
+
const table = (ts.read() || '').toString();
|
|
84
|
+
let result = '';
|
|
85
|
+
for (const row of table.split(/[\r\n]+/)) {
|
|
86
|
+
let r = row.replace(/[^┬]*┬/, '┌');
|
|
87
|
+
r = r.replace(/^├─*┼/, '├');
|
|
88
|
+
r = r.replace(/│[^│]*/, '');
|
|
89
|
+
r = r.replace(/^└─*┴/, '└');
|
|
90
|
+
r = r.replace(/'/g, ' ');
|
|
91
|
+
result += `${r}\n`;
|
|
92
|
+
}
|
|
93
|
+
console.log(result);
|
|
94
|
+
}
|
|
70
95
|
function emitSuccess(msg) {
|
|
71
96
|
console.log(chalk_1.default.green('success'), msg);
|
|
72
97
|
}
|
|
@@ -107,15 +107,39 @@ function renderCoverage(coverage) {
|
|
|
107
107
|
Logger.log(chalk.grey('}\n'));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
const logStatsResult = [
|
|
111
|
+
{
|
|
112
|
+
method: 'Types covered',
|
|
113
|
+
result: `${coverage.stats.numTypes > 0
|
|
114
|
+
? ((coverage.stats.numTypesCovered / coverage.stats.numTypes) * 100).toFixed(1)
|
|
115
|
+
: 'N/A'}%`,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
method: 'Types covered fully',
|
|
119
|
+
result: `${coverage.stats.numTypes > 0
|
|
120
|
+
? ((coverage.stats.numTypesCoveredFully / coverage.stats.numTypes) * 100).toFixed(1)
|
|
121
|
+
: 'N/A'}%`,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
method: 'Fields covered',
|
|
125
|
+
result: `${coverage.stats.numFields > 0
|
|
126
|
+
? ((coverage.stats.numFiledsCovered / coverage.stats.numFields) * 100).toFixed(1)
|
|
127
|
+
: 'N/A'}%`,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
method: 'Total Queries',
|
|
131
|
+
result: String(coverage.stats.numQueries > 0 ? coverage.stats.numQueries : '0'),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
method: 'Total Mutations',
|
|
135
|
+
result: String(coverage.stats.numMutations > 0 ? coverage.stats.numMutations : '0'),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
method: 'Total Subscriptions',
|
|
139
|
+
result: String(coverage.stats.numSubscriptions > 0 ? coverage.stats.numSubscriptions : '0'),
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
Logger.table(logStatsResult);
|
|
119
143
|
Logger.log(``);
|
|
120
144
|
}
|
|
121
145
|
function indent(line, space) {
|
|
@@ -11,6 +11,9 @@ export function coverage(schema, sources) {
|
|
|
11
11
|
numTypesCovered: 0,
|
|
12
12
|
numFields: 0,
|
|
13
13
|
numFiledsCovered: 0,
|
|
14
|
+
numQueries: 0,
|
|
15
|
+
numMutations: 0,
|
|
16
|
+
numSubscriptions: 0,
|
|
14
17
|
},
|
|
15
18
|
};
|
|
16
19
|
const typeMap = schema.getTypeMap();
|
|
@@ -59,6 +62,19 @@ export function coverage(schema, sources) {
|
|
|
59
62
|
type,
|
|
60
63
|
children: {},
|
|
61
64
|
};
|
|
65
|
+
if (isObjectType(type) || isInterfaceType(type)) {
|
|
66
|
+
switch (type.name) {
|
|
67
|
+
case 'Query':
|
|
68
|
+
coverage.stats.numQueries++;
|
|
69
|
+
break;
|
|
70
|
+
case 'Mutation':
|
|
71
|
+
coverage.stats.numMutations++;
|
|
72
|
+
break;
|
|
73
|
+
case 'Subscription':
|
|
74
|
+
coverage.stats.numSubscriptions++;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
62
78
|
const fieldMap = type.getFields();
|
|
63
79
|
for (const fieldname in fieldMap) {
|
|
64
80
|
const field = fieldMap[fieldname];
|
package/esm/logger/src/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Console } from 'node:console';
|
|
2
|
+
import { Transform } from 'node:stream';
|
|
1
3
|
import chalk from 'chalk';
|
|
2
4
|
import * as env from 'std-env';
|
|
3
5
|
export { default as figures } from 'figures';
|
|
@@ -19,6 +21,9 @@ export const Logger = {
|
|
|
19
21
|
log(msg) {
|
|
20
22
|
emit('log', msg);
|
|
21
23
|
},
|
|
24
|
+
table(input) {
|
|
25
|
+
table(input);
|
|
26
|
+
},
|
|
22
27
|
info(msg) {
|
|
23
28
|
emit('info', msg);
|
|
24
29
|
},
|
|
@@ -58,6 +63,26 @@ function emit(type, msg) {
|
|
|
58
63
|
console.log(msg);
|
|
59
64
|
}
|
|
60
65
|
}
|
|
66
|
+
function table(input) {
|
|
67
|
+
const ts = new Transform({
|
|
68
|
+
transform(chunk, _enc, cb) {
|
|
69
|
+
cb(null, chunk);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
const logger = new Console({ stdout: ts });
|
|
73
|
+
logger.table(input);
|
|
74
|
+
const table = (ts.read() || '').toString();
|
|
75
|
+
let result = '';
|
|
76
|
+
for (const row of table.split(/[\r\n]+/)) {
|
|
77
|
+
let r = row.replace(/[^┬]*┬/, '┌');
|
|
78
|
+
r = r.replace(/^├─*┼/, '├');
|
|
79
|
+
r = r.replace(/│[^│]*/, '');
|
|
80
|
+
r = r.replace(/^└─*┴/, '└');
|
|
81
|
+
r = r.replace(/'/g, ' ');
|
|
82
|
+
result += `${r}\n`;
|
|
83
|
+
}
|
|
84
|
+
console.log(result);
|
|
85
|
+
}
|
|
61
86
|
function emitSuccess(msg) {
|
|
62
87
|
console.log(chalk.green('success'), msg);
|
|
63
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/cli",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.17-alpha-20230425145409-b74fa0f2",
|
|
4
4
|
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -10,23 +10,23 @@
|
|
|
10
10
|
"@babel/core": "7.21.4",
|
|
11
11
|
"tslib": "2.5.0",
|
|
12
12
|
"yargs": "17.7.1",
|
|
13
|
-
"@graphql-inspector/audit-command": "3.4.
|
|
13
|
+
"@graphql-inspector/audit-command": "3.4.13-alpha-20230425145409-b74fa0f2",
|
|
14
14
|
"@graphql-inspector/code-loader": "3.4.4",
|
|
15
15
|
"@graphql-inspector/commands": "3.4.6",
|
|
16
16
|
"@graphql-inspector/config": "3.4.5",
|
|
17
|
-
"@graphql-inspector/coverage-command": "4.0.
|
|
18
|
-
"@graphql-inspector/diff-command": "3.4.
|
|
17
|
+
"@graphql-inspector/coverage-command": "4.0.9-alpha-20230425145409-b74fa0f2",
|
|
18
|
+
"@graphql-inspector/diff-command": "3.4.13-alpha-20230425145409-b74fa0f2",
|
|
19
19
|
"@graphql-inspector/docs-command": "3.4.7",
|
|
20
20
|
"@graphql-inspector/git-loader": "3.4.4",
|
|
21
21
|
"@graphql-inspector/github-loader": "3.4.4",
|
|
22
22
|
"@graphql-inspector/graphql-loader": "3.4.4",
|
|
23
|
-
"@graphql-inspector/introspect-command": "3.4.
|
|
23
|
+
"@graphql-inspector/introspect-command": "3.4.13-alpha-20230425145409-b74fa0f2",
|
|
24
24
|
"@graphql-inspector/json-loader": "3.4.4",
|
|
25
25
|
"@graphql-inspector/loaders": "3.4.6",
|
|
26
|
-
"@graphql-inspector/serve-command": "3.4.
|
|
27
|
-
"@graphql-inspector/similar-command": "3.4.
|
|
26
|
+
"@graphql-inspector/serve-command": "3.4.8-alpha-20230425145409-b74fa0f2",
|
|
27
|
+
"@graphql-inspector/similar-command": "3.4.13-alpha-20230425145409-b74fa0f2",
|
|
28
28
|
"@graphql-inspector/url-loader": "3.4.4",
|
|
29
|
-
"@graphql-inspector/validate-command": "3.5.
|
|
29
|
+
"@graphql-inspector/validate-command": "3.5.2-alpha-20230425145409-b74fa0f2"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -13,6 +13,10 @@ export interface Logger {
|
|
|
13
13
|
export declare const Logger: {
|
|
14
14
|
success(msg: string): void;
|
|
15
15
|
log(msg: string): void;
|
|
16
|
+
table(input: {
|
|
17
|
+
method: string;
|
|
18
|
+
result: string;
|
|
19
|
+
}[]): void;
|
|
16
20
|
info(msg: string): void;
|
|
17
21
|
error(msg: string): void;
|
|
18
22
|
warn(msg: string): void;
|
|
@@ -13,6 +13,10 @@ export interface Logger {
|
|
|
13
13
|
export declare const Logger: {
|
|
14
14
|
success(msg: string): void;
|
|
15
15
|
log(msg: string): void;
|
|
16
|
+
table(input: {
|
|
17
|
+
method: string;
|
|
18
|
+
result: string;
|
|
19
|
+
}[]): void;
|
|
16
20
|
info(msg: string): void;
|
|
17
21
|
error(msg: string): void;
|
|
18
22
|
warn(msg: string): void;
|