@graphql-inspector/coverage-command 0.0.0-canary.9cf9b2c → 0.0.0-canary.9daef8b
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.d.ts +11 -2
- package/{index.cjs.js → index.js} +44 -43
- package/{index.esm.js → index.mjs} +41 -42
- package/package.json +17 -7
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { GlobalArgs } from '@graphql-inspector/commands';
|
|
2
|
-
|
|
1
|
+
import { GlobalArgs, CommandFactory } from '@graphql-inspector/commands';
|
|
2
|
+
import { Source as DocumentSource } from '@graphql-tools/utils';
|
|
3
|
+
import { GraphQLSchema } from 'graphql';
|
|
4
|
+
export { CommandFactory };
|
|
5
|
+
export declare function handler({ schema, documents, silent, writePath, }: {
|
|
6
|
+
schema: GraphQLSchema;
|
|
7
|
+
documents: DocumentSource[];
|
|
8
|
+
silent?: boolean;
|
|
9
|
+
writePath?: string;
|
|
10
|
+
}): void;
|
|
11
|
+
declare const _default: CommandFactory<{}, {
|
|
3
12
|
schema: string;
|
|
4
13
|
documents: string;
|
|
5
14
|
write?: string | undefined;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
const tslib = require('tslib');
|
|
4
6
|
const commands = require('@graphql-inspector/commands');
|
|
5
7
|
const logger = require('@graphql-inspector/logger');
|
|
@@ -8,7 +10,35 @@ const graphql = require('graphql');
|
|
|
8
10
|
const path = require('path');
|
|
9
11
|
const fs = require('fs');
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
function handler({ schema, documents, silent, writePath, }) {
|
|
14
|
+
const shouldWrite = typeof writePath !== 'undefined';
|
|
15
|
+
const coverage = core.coverage(schema, documents.map(doc => new graphql.Source(graphql.print(doc.document), doc.location)));
|
|
16
|
+
if (silent !== true) {
|
|
17
|
+
renderCoverage(coverage);
|
|
18
|
+
}
|
|
19
|
+
if (shouldWrite) {
|
|
20
|
+
if (typeof writePath !== 'string') {
|
|
21
|
+
throw new Error(`--write is not valid file path: ${writePath}`);
|
|
22
|
+
}
|
|
23
|
+
const absPath = commands.ensureAbsolute(writePath);
|
|
24
|
+
const ext = path.extname(absPath).replace('.', '').toLocaleLowerCase();
|
|
25
|
+
let output = undefined;
|
|
26
|
+
if (ext === 'json') {
|
|
27
|
+
output = outputJSON(coverage);
|
|
28
|
+
}
|
|
29
|
+
if (output) {
|
|
30
|
+
fs.writeFileSync(absPath, output, {
|
|
31
|
+
encoding: 'utf-8',
|
|
32
|
+
});
|
|
33
|
+
logger.Logger.success(`Available at ${absPath}\n`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error(`Extension ${ext} is not supported`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const index = commands.createCommand(api => {
|
|
41
|
+
const { loaders } = api;
|
|
12
42
|
return {
|
|
13
43
|
command: 'coverage <documents> <schema>',
|
|
14
44
|
describe: 'Schema coverage based on documents',
|
|
@@ -38,40 +68,21 @@ const index = commands.createCommand((api) => {
|
|
|
38
68
|
});
|
|
39
69
|
},
|
|
40
70
|
handler(args) {
|
|
71
|
+
var _a;
|
|
41
72
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const { loaders } = api;
|
|
43
73
|
const writePath = args.write;
|
|
44
|
-
const
|
|
74
|
+
const silent = args.silent;
|
|
45
75
|
const { headers, token } = commands.parseGlobalArgs(args);
|
|
76
|
+
const apolloFederation = args.federation || false;
|
|
77
|
+
const aws = args.aws || false;
|
|
78
|
+
const method = ((_a = args.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'POST';
|
|
46
79
|
const schema = yield loaders.loadSchema(args.schema, {
|
|
47
80
|
token,
|
|
48
81
|
headers,
|
|
49
|
-
|
|
82
|
+
method,
|
|
83
|
+
}, apolloFederation, aws);
|
|
50
84
|
const documents = yield loaders.loadDocuments(args.documents);
|
|
51
|
-
|
|
52
|
-
if (args.silent !== true) {
|
|
53
|
-
renderCoverage(coverage);
|
|
54
|
-
}
|
|
55
|
-
if (shouldWrite) {
|
|
56
|
-
if (typeof writePath !== 'string') {
|
|
57
|
-
throw new Error(`--write is not valid file path: ${writePath}`);
|
|
58
|
-
}
|
|
59
|
-
const absPath = commands.ensureAbsolute(writePath);
|
|
60
|
-
const ext = path.extname(absPath).replace('.', '').toLocaleLowerCase();
|
|
61
|
-
let output = undefined;
|
|
62
|
-
if (ext === 'json') {
|
|
63
|
-
output = outputJSON(coverage);
|
|
64
|
-
}
|
|
65
|
-
if (output) {
|
|
66
|
-
fs.writeFileSync(absPath, output, {
|
|
67
|
-
encoding: 'utf-8',
|
|
68
|
-
});
|
|
69
|
-
logger.Logger.success(`Available at ${absPath}\n`);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
throw new Error(`Extension ${ext} is not supported`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
85
|
+
return handler({ schema, documents, silent, writePath });
|
|
75
86
|
});
|
|
76
87
|
},
|
|
77
88
|
};
|
|
@@ -84,25 +95,15 @@ function renderCoverage(coverage) {
|
|
|
84
95
|
for (const typeName in coverage.types) {
|
|
85
96
|
if (coverage.types.hasOwnProperty(typeName)) {
|
|
86
97
|
const typeCoverage = coverage.types[typeName];
|
|
87
|
-
logger.Logger.log([
|
|
88
|
-
logger.chalk.grey(core.getTypePrefix(typeCoverage.type)),
|
|
89
|
-
logger.chalk.bold(`${typeName}`),
|
|
90
|
-
logger.chalk.grey('{'),
|
|
91
|
-
].join(' '));
|
|
98
|
+
logger.Logger.log([logger.chalk.grey(core.getTypePrefix(typeCoverage.type)), logger.chalk.bold(`${typeName}`), logger.chalk.grey('{')].join(' '));
|
|
92
99
|
for (const childName in typeCoverage.children) {
|
|
93
100
|
if (typeCoverage.children.hasOwnProperty(childName)) {
|
|
94
101
|
const childCoverage = typeCoverage.children[childName];
|
|
95
102
|
if (childCoverage.hits) {
|
|
96
|
-
logger.Logger.log([
|
|
97
|
-
indent(childName, 2),
|
|
98
|
-
logger.chalk.italic.grey(`x ${childCoverage.hits}`),
|
|
99
|
-
].join(' '));
|
|
103
|
+
logger.Logger.log([indent(childName, 2), logger.chalk.italic.grey(`x ${childCoverage.hits}`)].join(' '));
|
|
100
104
|
}
|
|
101
105
|
else {
|
|
102
|
-
logger.Logger.log([
|
|
103
|
-
logger.chalk.redBright(indent(childName, 2)),
|
|
104
|
-
logger.chalk.italic.grey('x 0'),
|
|
105
|
-
].join(' '));
|
|
106
|
+
logger.Logger.log([logger.chalk.redBright(indent(childName, 2)), logger.chalk.italic.grey('x 0')].join(' '));
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -114,5 +115,5 @@ function indent(line, space) {
|
|
|
114
115
|
return line.padStart(line.length + space, ' ');
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
exports.default = index;
|
|
119
|
+
exports.handler = handler;
|
|
@@ -6,7 +6,35 @@ import { Source, print } from 'graphql';
|
|
|
6
6
|
import { extname } from 'path';
|
|
7
7
|
import { writeFileSync } from 'fs';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
function handler({ schema, documents, silent, writePath, }) {
|
|
10
|
+
const shouldWrite = typeof writePath !== 'undefined';
|
|
11
|
+
const coverage$1 = coverage(schema, documents.map(doc => new Source(print(doc.document), doc.location)));
|
|
12
|
+
if (silent !== true) {
|
|
13
|
+
renderCoverage(coverage$1);
|
|
14
|
+
}
|
|
15
|
+
if (shouldWrite) {
|
|
16
|
+
if (typeof writePath !== 'string') {
|
|
17
|
+
throw new Error(`--write is not valid file path: ${writePath}`);
|
|
18
|
+
}
|
|
19
|
+
const absPath = ensureAbsolute(writePath);
|
|
20
|
+
const ext = extname(absPath).replace('.', '').toLocaleLowerCase();
|
|
21
|
+
let output = undefined;
|
|
22
|
+
if (ext === 'json') {
|
|
23
|
+
output = outputJSON(coverage$1);
|
|
24
|
+
}
|
|
25
|
+
if (output) {
|
|
26
|
+
writeFileSync(absPath, output, {
|
|
27
|
+
encoding: 'utf-8',
|
|
28
|
+
});
|
|
29
|
+
Logger.success(`Available at ${absPath}\n`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new Error(`Extension ${ext} is not supported`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const index = createCommand(api => {
|
|
37
|
+
const { loaders } = api;
|
|
10
38
|
return {
|
|
11
39
|
command: 'coverage <documents> <schema>',
|
|
12
40
|
describe: 'Schema coverage based on documents',
|
|
@@ -36,40 +64,21 @@ const index = createCommand((api) => {
|
|
|
36
64
|
});
|
|
37
65
|
},
|
|
38
66
|
handler(args) {
|
|
67
|
+
var _a;
|
|
39
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const { loaders } = api;
|
|
41
69
|
const writePath = args.write;
|
|
42
|
-
const
|
|
70
|
+
const silent = args.silent;
|
|
43
71
|
const { headers, token } = parseGlobalArgs(args);
|
|
72
|
+
const apolloFederation = args.federation || false;
|
|
73
|
+
const aws = args.aws || false;
|
|
74
|
+
const method = ((_a = args.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'POST';
|
|
44
75
|
const schema = yield loaders.loadSchema(args.schema, {
|
|
45
76
|
token,
|
|
46
77
|
headers,
|
|
47
|
-
|
|
78
|
+
method,
|
|
79
|
+
}, apolloFederation, aws);
|
|
48
80
|
const documents = yield loaders.loadDocuments(args.documents);
|
|
49
|
-
|
|
50
|
-
if (args.silent !== true) {
|
|
51
|
-
renderCoverage(coverage$1);
|
|
52
|
-
}
|
|
53
|
-
if (shouldWrite) {
|
|
54
|
-
if (typeof writePath !== 'string') {
|
|
55
|
-
throw new Error(`--write is not valid file path: ${writePath}`);
|
|
56
|
-
}
|
|
57
|
-
const absPath = ensureAbsolute(writePath);
|
|
58
|
-
const ext = extname(absPath).replace('.', '').toLocaleLowerCase();
|
|
59
|
-
let output = undefined;
|
|
60
|
-
if (ext === 'json') {
|
|
61
|
-
output = outputJSON(coverage$1);
|
|
62
|
-
}
|
|
63
|
-
if (output) {
|
|
64
|
-
writeFileSync(absPath, output, {
|
|
65
|
-
encoding: 'utf-8',
|
|
66
|
-
});
|
|
67
|
-
Logger.success(`Available at ${absPath}\n`);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
throw new Error(`Extension ${ext} is not supported`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
81
|
+
return handler({ schema, documents, silent, writePath });
|
|
73
82
|
});
|
|
74
83
|
},
|
|
75
84
|
};
|
|
@@ -82,25 +91,15 @@ function renderCoverage(coverage) {
|
|
|
82
91
|
for (const typeName in coverage.types) {
|
|
83
92
|
if (coverage.types.hasOwnProperty(typeName)) {
|
|
84
93
|
const typeCoverage = coverage.types[typeName];
|
|
85
|
-
Logger.log([
|
|
86
|
-
chalk.grey(getTypePrefix(typeCoverage.type)),
|
|
87
|
-
chalk.bold(`${typeName}`),
|
|
88
|
-
chalk.grey('{'),
|
|
89
|
-
].join(' '));
|
|
94
|
+
Logger.log([chalk.grey(getTypePrefix(typeCoverage.type)), chalk.bold(`${typeName}`), chalk.grey('{')].join(' '));
|
|
90
95
|
for (const childName in typeCoverage.children) {
|
|
91
96
|
if (typeCoverage.children.hasOwnProperty(childName)) {
|
|
92
97
|
const childCoverage = typeCoverage.children[childName];
|
|
93
98
|
if (childCoverage.hits) {
|
|
94
|
-
Logger.log([
|
|
95
|
-
indent(childName, 2),
|
|
96
|
-
chalk.italic.grey(`x ${childCoverage.hits}`),
|
|
97
|
-
].join(' '));
|
|
99
|
+
Logger.log([indent(childName, 2), chalk.italic.grey(`x ${childCoverage.hits}`)].join(' '));
|
|
98
100
|
}
|
|
99
101
|
else {
|
|
100
|
-
Logger.log([
|
|
101
|
-
chalk.redBright(indent(childName, 2)),
|
|
102
|
-
chalk.italic.grey('x 0'),
|
|
103
|
-
].join(' '));
|
|
102
|
+
Logger.log([chalk.redBright(indent(childName, 2)), chalk.italic.grey('x 0')].join(' '));
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
}
|
|
@@ -113,4 +112,4 @@ function indent(line, space) {
|
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
export default index;
|
|
116
|
-
|
|
115
|
+
export { handler };
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/coverage-command",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.9daef8b",
|
|
4
4
|
"description": "Schema Coverage in GraphQL Inspector",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0"
|
|
7
|
+
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-inspector/commands": "0.0.0-canary.
|
|
11
|
-
"@graphql-inspector/core": "0.0.0-canary.
|
|
12
|
-
"@graphql-inspector/logger": "0.0.0-canary.
|
|
10
|
+
"@graphql-inspector/commands": "0.0.0-canary.9daef8b",
|
|
11
|
+
"@graphql-inspector/core": "0.0.0-canary.9daef8b",
|
|
12
|
+
"@graphql-inspector/logger": "0.0.0-canary.9daef8b",
|
|
13
13
|
"tslib": "^2.0.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
@@ -29,10 +29,20 @@
|
|
|
29
29
|
"url": "https://github.com/kamilkisiela"
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"main": "index.
|
|
33
|
-
"module": "index.
|
|
32
|
+
"main": "index.js",
|
|
33
|
+
"module": "index.mjs",
|
|
34
34
|
"typings": "index.d.ts",
|
|
35
35
|
"typescript": {
|
|
36
36
|
"definition": "index.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"require": "./index.js",
|
|
41
|
+
"import": "./index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./*": {
|
|
44
|
+
"require": "./*.js",
|
|
45
|
+
"import": "./*.mjs"
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
}
|
package/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../dist/commands/coverage/src/index.js"],"sourcesContent":["import { __awaiter } from \"tslib\";\nimport { createCommand, ensureAbsolute, parseGlobalArgs, } from '@graphql-inspector/commands';\nimport { Logger, chalk } from '@graphql-inspector/logger';\nimport { coverage as calculateCoverage, getTypePrefix, } from '@graphql-inspector/core';\nimport { Source, print } from 'graphql';\nimport { extname } from 'path';\nimport { writeFileSync } from 'fs';\nexport default createCommand((api) => {\n return {\n command: 'coverage <documents> <schema>',\n describe: 'Schema coverage based on documents',\n builder(yargs) {\n return yargs\n .positional('schema', {\n describe: 'Point to a schema',\n type: 'string',\n demandOption: true,\n })\n .positional('documents', {\n describe: 'Point to documents',\n type: 'string',\n demandOption: true,\n })\n .options({\n w: {\n alias: 'write',\n describe: 'Write a file with coverage stats',\n type: 'string',\n },\n s: {\n alias: 'silent',\n describe: 'Do not render any stats in the terminal',\n type: 'boolean',\n },\n });\n },\n handler(args) {\n return __awaiter(this, void 0, void 0, function* () {\n const { loaders } = api;\n const writePath = args.write;\n const shouldWrite = typeof writePath !== 'undefined';\n const { headers, token } = parseGlobalArgs(args);\n const schema = yield loaders.loadSchema(args.schema, {\n token,\n headers,\n });\n const documents = yield loaders.loadDocuments(args.documents);\n const coverage = calculateCoverage(schema, documents.map((doc) => new Source(print(doc.document), doc.location)));\n if (args.silent !== true) {\n renderCoverage(coverage);\n }\n if (shouldWrite) {\n if (typeof writePath !== 'string') {\n throw new Error(`--write is not valid file path: ${writePath}`);\n }\n const absPath = ensureAbsolute(writePath);\n const ext = extname(absPath).replace('.', '').toLocaleLowerCase();\n let output = undefined;\n if (ext === 'json') {\n output = outputJSON(coverage);\n }\n if (output) {\n writeFileSync(absPath, output, {\n encoding: 'utf-8',\n });\n Logger.success(`Available at ${absPath}\\n`);\n }\n else {\n throw new Error(`Extension ${ext} is not supported`);\n }\n }\n });\n },\n };\n});\nfunction outputJSON(coverage) {\n return JSON.stringify(coverage, null, 2);\n}\nfunction renderCoverage(coverage) {\n Logger.info('Schema coverage based on documents:\\n');\n for (const typeName in coverage.types) {\n if (coverage.types.hasOwnProperty(typeName)) {\n const typeCoverage = coverage.types[typeName];\n Logger.log([\n chalk.grey(getTypePrefix(typeCoverage.type)),\n chalk.bold(`${typeName}`),\n chalk.grey('{'),\n ].join(' '));\n for (const childName in typeCoverage.children) {\n if (typeCoverage.children.hasOwnProperty(childName)) {\n const childCoverage = typeCoverage.children[childName];\n if (childCoverage.hits) {\n Logger.log([\n indent(childName, 2),\n chalk.italic.grey(`x ${childCoverage.hits}`),\n ].join(' '));\n }\n else {\n Logger.log([\n chalk.redBright(indent(childName, 2)),\n chalk.italic.grey('x 0'),\n ].join(' '));\n }\n }\n }\n Logger.log(chalk.grey('}\\n'));\n }\n }\n}\nfunction indent(line, space) {\n return line.padStart(line.length + space, ' ');\n}\n//# sourceMappingURL=index.js.map"],"names":["createCommand","__awaiter","parseGlobalArgs","calculateCoverage","Source","print","ensureAbsolute","extname","writeFileSync","Logger","chalk","getTypePrefix"],"mappings":";;;;;;;;;;AAOA,cAAeA,sBAAa,CAAC,CAAC,GAAG,KAAK;AACtC,IAAI,OAAO;AACX,QAAQ,OAAO,EAAE,+BAA+B;AAChD,QAAQ,QAAQ,EAAE,oCAAoC;AACtD,QAAQ,OAAO,CAAC,KAAK,EAAE;AACvB,YAAY,OAAO,KAAK;AACxB,iBAAiB,UAAU,CAAC,QAAQ,EAAE;AACtC,gBAAg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AAChD,4BAA4BC,YAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AACxE,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,qBAAqB;AACrB,yBAAyB;AACzB,wBAAwBD,aAAM,CAAC,GAAG,CAAC;AACnC,4BAA4BC,YAAK,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AACjE,4BAA4BA,YAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;AACpD,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,YAAYD,aAAM,CAAC,GAAG,CAACC,YAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,SAAS;AACT,KAAK;AACL,CAAC;AACD,SAAS,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE;AAC7B,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;AACnD;;;;"}
|
package/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../dist/commands/coverage/src/index.js"],"sourcesContent":["import { __awaiter } from \"tslib\";\nimport { createCommand, ensureAbsolute, parseGlobalArgs, } from '@graphql-inspector/commands';\nimport { Logger, chalk } from '@graphql-inspector/logger';\nimport { coverage as calculateCoverage, getTypePrefix, } from '@graphql-inspector/core';\nimport { Source, print } from 'graphql';\nimport { extname } from 'path';\nimport { writeFileSync } from 'fs';\nexport default createCommand((api) => {\n return {\n command: 'coverage <documents> <schema>',\n describe: 'Schema coverage based on documents',\n builder(yargs) {\n return yargs\n .positional('schema', {\n describe: 'Point to a schema',\n type: 'string',\n demandOption: true,\n })\n .positional('documents', {\n describe: 'Point to documents',\n type: 'string',\n demandOption: true,\n })\n .options({\n w: {\n alias: 'write',\n describe: 'Write a file with coverage stats',\n type: 'string',\n },\n s: {\n alias: 'silent',\n describe: 'Do not render any stats in the terminal',\n type: 'boolean',\n },\n });\n },\n handler(args) {\n return __awaiter(this, void 0, void 0, function* () {\n const { loaders } = api;\n const writePath = args.write;\n const shouldWrite = typeof writePath !== 'undefined';\n const { headers, token } = parseGlobalArgs(args);\n const schema = yield loaders.loadSchema(args.schema, {\n token,\n headers,\n });\n const documents = yield loaders.loadDocuments(args.documents);\n const coverage = calculateCoverage(schema, documents.map((doc) => new Source(print(doc.document), doc.location)));\n if (args.silent !== true) {\n renderCoverage(coverage);\n }\n if (shouldWrite) {\n if (typeof writePath !== 'string') {\n throw new Error(`--write is not valid file path: ${writePath}`);\n }\n const absPath = ensureAbsolute(writePath);\n const ext = extname(absPath).replace('.', '').toLocaleLowerCase();\n let output = undefined;\n if (ext === 'json') {\n output = outputJSON(coverage);\n }\n if (output) {\n writeFileSync(absPath, output, {\n encoding: 'utf-8',\n });\n Logger.success(`Available at ${absPath}\\n`);\n }\n else {\n throw new Error(`Extension ${ext} is not supported`);\n }\n }\n });\n },\n };\n});\nfunction outputJSON(coverage) {\n return JSON.stringify(coverage, null, 2);\n}\nfunction renderCoverage(coverage) {\n Logger.info('Schema coverage based on documents:\\n');\n for (const typeName in coverage.types) {\n if (coverage.types.hasOwnProperty(typeName)) {\n const typeCoverage = coverage.types[typeName];\n Logger.log([\n chalk.grey(getTypePrefix(typeCoverage.type)),\n chalk.bold(`${typeName}`),\n chalk.grey('{'),\n ].join(' '));\n for (const childName in typeCoverage.children) {\n if (typeCoverage.children.hasOwnProperty(childName)) {\n const childCoverage = typeCoverage.children[childName];\n if (childCoverage.hits) {\n Logger.log([\n indent(childName, 2),\n chalk.italic.grey(`x ${childCoverage.hits}`),\n ].join(' '));\n }\n else {\n Logger.log([\n chalk.redBright(indent(childName, 2)),\n chalk.italic.grey('x 0'),\n ].join(' '));\n }\n }\n }\n Logger.log(chalk.grey('}\\n'));\n }\n }\n}\nfunction indent(line, space) {\n return line.padStart(line.length + space, ' ');\n}\n//# sourceMappingURL=index.js.map"],"names":["coverage","calculateCoverage"],"mappings":";;;;;;;;AAOA,cAAe,aAAa,CAAC,CAAC,GAAG,KAAK;AACtC,IAAI,OAAO;AACX,QAAQ,OAAO,EAAE,+BAA+B;AAChD,QAAQ,QAAQ,EAAE,oCAAoC;AACtD,QAAQ,OAAO,CAAC,KAAK,EAAE;AACvB,YAAY,OAAO,KAAK;AACxB,iBAAiB,UAAU,CAAC,QAAQ,EAAE;AACtC,gBAAgB,QAAQ,EAAE,mBAAmB;AAC7C,gBAAgB,IAAI,EAAE,QAAQ;AAC9B,gBAAgB,YAAY,EAAE,IAAI;AAClC,aAAa,CAAC;AACd,iBAAiB,UAAU,CAAC,WAAW,EAAE;AACzC,gBAAgB,QAAQ,EAAE,oBAAoB;AAC9C,gBAAgB,IAAI,EAAE,QAAQ;AAC9B,gBAAgB,YAAY,EAAE,IAAI;AAClC,aAAa,CAAC;AACd,iBAAiB,OAAO,CAAC;AACzB,gBAAgB,CAAC,EAAE;AACnB,oBAAoB,KAAK,EAAE,OAAO;AAClC,oBAAoB,QAAQ,EAAE,kCAAkC;AAChE,oBAAoB,IAAI,EAAE,QAAQ;AAClC,iBAAiB;AACjB,gBAAgB,CAAC,EAAE;AACnB,oBAAoB,KAAK,EAAE,QAAQ;AACnC,oBAAoB,QAAQ,EAAE,yCAAyC;AACvE,oBAAoB,IAAI,EAAE,SAAS;AACnC,iBAAiB;AACjB,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,OAAO,CAAC,IAAI,EAAE;AACtB,YAAY,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,aAAa;AAChE,gBAAgB,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;AACxC,gBAAgB,MAAM,SAAS,GAAG,IAAI,CAAC,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