Merge branch 'next' into next-passport

This commit is contained in:
Wyatt Johnson
2018-08-01 13:13:54 -06:00
5 changed files with 100 additions and 61 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env ts-node
import program from "commander";
import spawn from "cross-spawn";
import fs from "fs";
import path from "path";
const config = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "../.graphqlconfig"), "utf8")
);
program
.version("0.1.0")
.usage("--src ./src/core/client/stream --schema tenant")
.option("--src <folder>", "Find gql recursively in this folder")
.option("--schema <schema>", "Identifier of schema")
.description("Compile relay gql data")
.parse(process.argv);
if (!program.schema) {
// tslint:disable-next-line:no-console
console.error("Schema identifier not provided");
process.exit(1);
}
if (!program.src) {
// tslint:disable-next-line:no-console
console.error("Src not provided");
process.exit(1);
}
if (!config.projects) {
// tslint:disable-next-line:no-console
console.error("Missing projects key in .graphqconfig");
process.exit(1);
}
if (!config.projects[program.schema]) {
// tslint:disable-next-line:no-console
console.error(`Project ${program.schema} not found in .graphqconfig`);
process.exit(1);
}
if (!config.projects[program.schema].schemaPath) {
// tslint:disable-next-line:no-console
console.error(
`SchemaPath for project ${program.schema} not found in .graphqconfig`
);
process.exit(1);
}
const args = [
"--language",
"typescript",
"--no-watchman",
"--src",
program.src,
"--artifactDirectory",
`${program.src}/__generated__`,
"--schema",
config.projects[program.schema].schemaPath,
];
spawn.sync("relay-compiler", args, { stdio: "inherit" });
-39
View File
@@ -1,39 +0,0 @@
#!/usr/bin/env ts-node
import program from "commander";
import fs from "fs";
import path from "path";
const config = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "../.graphqlconfig"), "utf8")
);
program
.version("0.1.0")
.usage("<project>")
.arguments("<project>")
.description(
"Returns the schema graph in `.graphqlconfig` based on <project>"
)
.action(project => {
if (!config.projects) {
// tslint:disable-next-line:no-console
console.error("Missing projects key in .graphqconfig");
process.exit(1);
}
if (!config.projects[project]) {
// tslint:disable-next-line:no-console
console.error(`Project ${project} not found in .graphqconfig`);
process.exit(1);
}
if (!config.projects[project].schemaPath) {
// tslint:disable-next-line:no-console
console.error(
`SchemaPath for project ${project} not found in .graphqconfig`
);
process.exit(1);
}
// tslint:disable-next-line:no-console
console.log(config.projects[project].schemaPath);
})
.parse(process.argv);