@kube/vgql-cli
Advanced tools
Comparing version 0.0.6 to 0.0.7
// src/cli.ts | ||
import { program } from "@commander-js/extra-typings"; | ||
import { mergeTypeDefs } from "@graphql-tools/merge"; | ||
import { print } from "graphql"; | ||
import { serializeSchemas } from "@kube/vgql-structype"; | ||
@@ -15,7 +17,10 @@ import { toStructypeSchema } from "@kube/vgql-structype-graphql"; | ||
program.name("vgql").description("Virtual GraphQL CLI").version("0.0.1"); | ||
program.command("generate <file>").option("-w, --watch", "watch mode").requiredOption("-o, --out <path>", "output path").description("Generate Structype from GraphQL Schema").action((fileName, options) => { | ||
program.command("generate <schemaFiles...>").option("-w, --watch", "watch mode").requiredOption("-o, --out <path>", "output path").description("Generate Structype from GraphQL Schema").action((schemaFiles, options) => { | ||
async function transpileAndWrite() { | ||
try { | ||
const fileContent = readFileSync(fileName, "utf-8"); | ||
const structype = toStructypeSchema(fileContent); | ||
const filesContent = schemaFiles.map( | ||
(fileName) => readFileSync(fileName, "utf-8") | ||
); | ||
const mergedSchema = print(mergeTypeDefs(filesContent)); | ||
const structype = toStructypeSchema(mergedSchema); | ||
const serialized = serializeSchemas(structype); | ||
@@ -34,3 +39,5 @@ const formatted = await format(serialized); | ||
if (options.watch) { | ||
watchFile(fileName, { interval: 200 }, transpileAndWrite); | ||
schemaFiles.forEach( | ||
(fileName) => watchFile(fileName, { interval: 200 }, transpileAndWrite) | ||
); | ||
} | ||
@@ -37,0 +44,0 @@ }); |
{ | ||
"name": "@kube/vgql-cli", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"author": "Chris Feijoo", | ||
@@ -10,7 +10,9 @@ "license": "MIT", | ||
"@commander-js/extra-typings": "^11.1.0", | ||
"@graphql-tools/merge": "^9.0.4", | ||
"body-parser": "^1.20.2", | ||
"commander": "^11.1.0", | ||
"express": "^4.19.2", | ||
"graphql": "^16.8.1", | ||
"prettier": "^3.2.1", | ||
"@kube/vgql-core": "0.0.5", | ||
"@kube/vgql-core": "0.0.6", | ||
"@kube/vgql-structype": "0.0.5", | ||
@@ -17,0 +19,0 @@ "@kube/vgql-structype-graphql": "0.0.5" |
import { program } from "@commander-js/extra-typings"; | ||
import { mergeTypeDefs } from "@graphql-tools/merge"; | ||
import { print } from "graphql"; | ||
@@ -19,11 +21,14 @@ import { serializeSchemas } from "@kube/vgql-structype"; | ||
program | ||
.command("generate <file>") | ||
.command("generate <schemaFiles...>") | ||
.option("-w, --watch", "watch mode") | ||
.requiredOption("-o, --out <path>", "output path") | ||
.description("Generate Structype from GraphQL Schema") | ||
.action((fileName, options) => { | ||
.action((schemaFiles, options) => { | ||
async function transpileAndWrite() { | ||
try { | ||
const fileContent = readFileSync(fileName, "utf-8"); | ||
const structype = toStructypeSchema(fileContent); | ||
const filesContent = schemaFiles.map((fileName) => | ||
readFileSync(fileName, "utf-8") | ||
); | ||
const mergedSchema = print(mergeTypeDefs(filesContent)); | ||
const structype = toStructypeSchema(mergedSchema); | ||
const serialized = serializeSchemas(structype); | ||
@@ -44,3 +49,6 @@ const formatted = await format(serialized); | ||
if (options.watch) { | ||
watchFile(fileName, { interval: 200 }, transpileAndWrite); | ||
// TODO: Watcher should not be done like that | ||
schemaFiles.forEach((fileName) => | ||
watchFile(fileName, { interval: 200 }, transpileAndWrite) | ||
); | ||
} | ||
@@ -47,0 +55,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20989
281
10
+ Added@graphql-tools/merge@^9.0.4
+ Addedgraphql@^16.8.1
+ Added@kube/vgql-core@0.0.6(transitive)
- Removed@kube/vgql-core@0.0.5(transitive)
Updated@kube/vgql-core@0.0.6