-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (52 loc) · 1.95 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
const AWS = require("aws-sdk");
const program = require("commander");
const lint = require("./src/lint");
const uploadSchema = require("./src/upload_schema");
const uploadOperations = require("./src/upload_operations");
function clientFromOptions(options) {
return new AWS.S3({
endpoint: options.aws_endpoint || process.env.AWS_ENDPOINT,
accessKeyId: options.aws_access_key_id || process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: options.aws_secret_access_key || process.env.AWS_SECRET_ACCESS_KEY
});
}
program
.command("upload-schema <schema>")
.description("upload a graphql schema")
.option("--aws_endpoint [key]", "The AWS endpoint")
.option("--aws_access_key_id [key]", "AWS access key id")
.option("--aws_secret_access_key [key]", "AWS secret access key")
.option("--tag [tag]", "The schema tag $name:$branch:$commit")
.action((schema, options) => {
uploadSchema(clientFromOptions(options), {
schemaPath: schema,
tag: options.tag
});
});
program
.command("upload-operations <files...>")
.description("upload graphql operations ")
.option("--aws_endpoint [key]", "The AWS endpoint")
.option("--aws_access_key_id [key]", "AWS access key id")
.option("--aws_secret_access_key [key]", "AWS secret access key")
.option("--tag [tag]", "The schema tag $name:$branch:$commit")
.action((files, options) => {
uploadOperations(clientFromOptions(options), {
operationsFilePaths: files,
tag: options.tag
});
});
program
.command("lint <operations_tags...>")
.description("upload graphql operations")
.option("--aws_endpoint [key]", "The AWS endpoint")
.option("--aws_access_key_id [key]", "AWS access key id")
.option("--aws_secret_access_key [key]", "AWS secret access key")
.option("--schema_tag [tag]", "The schema tag")
.action((tags, options) => {
lint(clientFromOptions(options), {
schemaTag: options.schema_tag,
operationsTags: tags
});
});
program.parse(process.argv);