@axinom/mosaic-cli 0.9.5-rc.5 → 0.10.0-rc.2
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/dist/cli/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const yargs = require("yargs");
|
|
|
6
6
|
const apply_templates_1 = require("../commands/apply-templates");
|
|
7
7
|
const create_extension_config_1 = require("../commands/create-extension-config");
|
|
8
8
|
const get_access_token_1 = require("../commands/get-access-token");
|
|
9
|
+
const graphql_diff_1 = require("../commands/graphql-diff");
|
|
9
10
|
const msg_codegen_1 = require("../commands/msg-codegen");
|
|
10
11
|
const pg_dump_1 = require("../commands/pg-dump");
|
|
11
12
|
const publish_schema_to_db_1 = require("../commands/publish-schema-to-db");
|
|
@@ -39,7 +40,8 @@ const run = () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
|
39
40
|
.command(publish_schema_to_db_1.publishSchemaToDb)
|
|
40
41
|
.command(pg_dump_1.pgDump)
|
|
41
42
|
.command(msg_codegen_1.msgCodegen)
|
|
42
|
-
.command(create_extension_config_1.createExtensionConfigCommand)
|
|
43
|
+
.command(create_extension_config_1.createExtensionConfigCommand)
|
|
44
|
+
.command(graphql_diff_1.graphqlDiff);
|
|
43
45
|
//adding cli extensions:
|
|
44
46
|
yield Promise.all((0, create_extension_config_1.getExtensions)().map((library) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
45
47
|
try {
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,iEAA6D;AAC7D,iFAG6C;AAC7C,mEAA8D;AAC9D,yDAAqD;AACrD,iDAA6C;AAC7C,2EAAqE;AAE9D,MAAM,GAAG,GAAG,GAAwB,EAAE;IAC3C,KAAK;SACF,UAAU,CAAC,QAAQ,CAAC;SACp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
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/** Script to check graphql schemas for breaking changes
|
|
6
|
+
* Uses: https://www.npmjs.com/package/@graphql-inspector/core
|
|
7
|
+
* The associated CLI tool (https://www.npmjs.com/package/@graphql-inspector/cli)
|
|
8
|
+
* is simple to use but inflexible for our use case.
|
|
9
|
+
*/
|
|
10
|
+
/* eslint-disable no-console */
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
|
+
const core_1 = require("@graphql-inspector/core");
|
|
13
|
+
const chalk_1 = require("chalk");
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const graphql_1 = require("graphql");
|
|
17
|
+
const path = require("path");
|
|
18
|
+
exports.graphqlDiff = {
|
|
19
|
+
command: 'graphql-diff',
|
|
20
|
+
describe: 'Compares graphql schema(s) with git for breaking changes.',
|
|
21
|
+
builder: (yargs) => yargs
|
|
22
|
+
.options('files', {
|
|
23
|
+
alias: 'f',
|
|
24
|
+
describe: 'The .graphql file(s) to check. Each will be checked against git.',
|
|
25
|
+
type: 'array',
|
|
26
|
+
demand: true,
|
|
27
|
+
})
|
|
28
|
+
.option('branch', {
|
|
29
|
+
alias: 'b',
|
|
30
|
+
description: 'Git branch or commit identifier to compare to.',
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: 'origin/master',
|
|
33
|
+
})
|
|
34
|
+
.option('verbose', {
|
|
35
|
+
alias: 'v',
|
|
36
|
+
description: 'Verbose output including non-breaking changes',
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
default: false,
|
|
39
|
+
}),
|
|
40
|
+
handler: (argv) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
41
|
+
let totalBreaking = 0;
|
|
42
|
+
try {
|
|
43
|
+
for (const file of argv.files) {
|
|
44
|
+
totalBreaking += yield gqlDiff(file.toString(), argv.branch, argv.verbose);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
console.log((0, chalk_1.red)(e));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
if (totalBreaking > 0) {
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
function gqlDiff(file, branch, verbose) {
|
|
57
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
58
|
+
const root = path.dirname(__dirname);
|
|
59
|
+
const relPath = path.relative(root, file);
|
|
60
|
+
console.log(`Comparing schema '${relPath}' with branch '${branch}':`);
|
|
61
|
+
let schema1 = undefined;
|
|
62
|
+
let schema2 = undefined;
|
|
63
|
+
// load schemas
|
|
64
|
+
try {
|
|
65
|
+
const buffer = yield fs.promises.readFile(file);
|
|
66
|
+
schema2 = (0, graphql_1.buildSchema)(buffer.toString());
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
throw `Error reading ${file}: ${e.toString()}`;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const text = readFileFromGit(branch, path.resolve(file));
|
|
73
|
+
schema1 = (0, graphql_1.buildSchema)(text);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
if (e.toString().includes(`exists on disk, but not in '${branch}'`)) {
|
|
77
|
+
console.log(e.toString());
|
|
78
|
+
console.log(`WARNING: Check will be skipped on the assumption that this is a new schema.`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
throw `Error reading ${file} from branch ${branch}: ${e}`;
|
|
82
|
+
}
|
|
83
|
+
// generate diff
|
|
84
|
+
const diffResult = yield (0, core_1.diff)(schema1, schema2);
|
|
85
|
+
const breaking = diffResult.filter((r) => r.criticality.level === core_1.CriticalityLevel.Breaking);
|
|
86
|
+
// log results
|
|
87
|
+
if (breaking.length > 0 || verbose) {
|
|
88
|
+
for (const item of diffResult) {
|
|
89
|
+
if (item.criticality.level === core_1.CriticalityLevel.Breaking) {
|
|
90
|
+
console.log(` ✖ ${item.message}`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.log(` ✔ ${item.message}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const color = breaking.length > 0 ? chalk_1.red : chalk_1.green;
|
|
98
|
+
console.log(color(`${breaking.length > 0 ? '❌ ' : ''}${breaking.length} breaking change${breaking.length === 1 ? '' : 's'}`));
|
|
99
|
+
return breaking.length;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function readFileFromGit(branch, file) {
|
|
103
|
+
const root = (0, child_process_1.execSync)(`git -C ${path
|
|
104
|
+
.dirname(file)
|
|
105
|
+
.replace(/\\/g, '/')} rev-parse --show-toplevel`)
|
|
106
|
+
.toString()
|
|
107
|
+
.trim();
|
|
108
|
+
return (0, child_process_1.execSync)(`git -C ${root} show ${branch}:${path
|
|
109
|
+
.relative(root, file)
|
|
110
|
+
.replace(/\\/g, '/')}`).toString();
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=graphql-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-diff.js","sourceRoot":"","sources":["../../src/commands/graphql-diff.ts"],"names":[],"mappings":";;;;AAAA;;;;GAIG;AACH,+BAA+B;AAC/B,uDAAuD;AACvD,kDAAiE;AACjE,iCAAmC;AACnC,iDAAyC;AACzC,yBAAyB;AACzB,qCAAqD;AACrD,6BAA6B;AAShB,QAAA,WAAW,GAA+C;IACrE,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,2DAA2D;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,OAAO,CAAC,OAAO,EAAE;QAChB,KAAK,EAAE,GAAG;QACV,QAAQ,EACN,kEAAkE;QACpE,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,IAAI;KACb,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,KAAK,EAAE,GAAG;QACV,W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IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;iBACpC;aACF;SACF;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAG,CAAC,CAAC,CAAC,aAAK,CAAC;QAChD,OAAO,CAAC,GAAG,CACT,KAAK,CACH,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,mBAClD,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC/B,EAAE,CACH,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;CAAA;AAED,SAAS,eAAe,CAAC,MAAc,EAAE,IAAY;IACnD,MAAM,IAAI,GAAG,IAAA,wBAAQ,EACnB,UAAU,IAAI;SACX,OAAO,CAAC,IAAI,CAAC;SACb,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,4BAA4B,CACnD;SACE,QAAQ,EAAE;SACV,IAAI,EAAE,CAAC;IACV,OAAO,IAAA,wBAAQ,EACb,UAAU,IAAI,SAAS,MAAM,IAAI,IAAI;SAClC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CACzB,CAAC,QAAQ,EAAE,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-rc.2",
|
|
4
4
|
"description": "The Axinom Mosaic CLI",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@asyncapi/modelina": "^0.43.0",
|
|
30
30
|
"@asyncapi/parser": "^1.13.2",
|
|
31
|
-
"@axinom/mosaic-id-link-be": "^0.6.5-rc.
|
|
32
|
-
"@axinom/mosaic-service-common": "^0.19.0-rc.
|
|
31
|
+
"@axinom/mosaic-id-link-be": "^0.6.5-rc.8",
|
|
32
|
+
"@axinom/mosaic-service-common": "^0.19.0-rc.7",
|
|
33
|
+
"@graphql-inspector/core": "^3.1.2",
|
|
33
34
|
"@stoplight/spectral": "^5.9.1",
|
|
34
35
|
"chalk": "^4.1.0",
|
|
35
36
|
"diff": "^5.0.0",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"access": "public"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b50606f1af27d7a239c45350a509387fe9fb1095"
|
|
64
65
|
}
|