forked from apollosolutions/multi-check-publish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
91 lines (83 loc) · 2.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env node
import meow from "meow";
import { check } from "./src/check.js";
import { publish } from "./src/publish.js";
const cli = meow(
`
Experimental wrapper around Apollo Rover.
USAGE
$ @apollosolutions/roverx supergraph check mygraph@current --config config.yaml
$ @apollosolutions/roverx supergraph publish mygraph@current --config config.yaml
FLAGS
--config <config-path> The relative path to the supergraph configuration file. See
https://www.apollographql.com/docs/rover/supergraphs/#configuration
-l, --log <log-level> Specify Rover's log level [possible values: error, warn, info,
debug, trace]
--profile <profile-name> Name of configuration profile to use [default: default]
-H, --header <key:value>... Headers to pass to the endpoint if using subgraph_url in your
config. Values must be key:value pairs. If a value has a space
in it, use quotes around the pair, ex. -H "Auth:some key"
CHECK FLAGS
--query-count-threshold <query-count-threshold>
--query-percentage-threshold <query-percentage-threshold>
--validation-period <validation-period>
`,
{
importMeta: import.meta,
flags: {
config: {
type: "string",
isRequired: true,
},
log: {
type: "string",
alias: "l",
},
profile: {
type: "string",
},
header: {
type: "string",
alias: "H",
isMultiple: true,
},
queryCountThreshold: {
type: "string",
},
queryPercentageThreshold: {
type: "string",
},
validationPeriod: {
type: "string",
},
},
}
);
switch (cli.input[0]) {
case "supergraph":
switch (cli.input[1]) {
case "check": {
if (!cli.input[2]) {
console.error(`<graphRef> missing`);
process.exit(1);
}
check({ graphRef: cli.input[2], ...cli.flags });
break;
}
case "publish": {
if (!cli.input[2]) {
console.error(`<graphRef> missing`);
process.exit(1);
}
publish({ graphRef: cli.input[2], ...cli.flags });
break;
}
default:
console.error(`Invalid command ${cli.input[1]}`);
process.exit(1);
}
break;
default:
console.error(`Invalid command ${cli.input[0]}`);
process.exit(1);
}