@kube/vgql-cli
Advanced tools
Comparing version 0.0.1 to 0.0.3
101
dist/cli.js
@@ -0,6 +1,42 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/cli.ts | ||
import { program } from "@commander-js/extra-typings"; | ||
import { serializeSchemas } from "@kube/vgql-structype"; | ||
import { toStructypeSchema } from "@kube/vgql-structype-graphql"; | ||
import { readFileSync, watchFile, writeFileSync } from "fs"; | ||
var cli_exports = {}; | ||
__export(cli_exports, { | ||
format: () => format | ||
}); | ||
module.exports = __toCommonJS(cli_exports); | ||
var import_extra_typings = require("@commander-js/extra-typings"); | ||
var import_path = require("path"); | ||
var import_vgql_core = require("@kube/vgql-core"); | ||
var import_vgql_structype = require("@kube/vgql-structype"); | ||
var import_vgql_structype_graphql = require("@kube/vgql-structype-graphql"); | ||
var import_fs = require("fs"); | ||
async function format(code) { | ||
@@ -14,11 +50,11 @@ try { | ||
} | ||
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) => { | ||
import_extra_typings.program.name("vgql").description("Virtual GraphQL CLI").version("0.0.1"); | ||
import_extra_typings.program.command("generate <file>").option("-w, --watch", "watch mode").requiredOption("-o, --out <path>", "output path").description("Generate Structype from GraphQL Schema").action((fileName, options) => { | ||
async function transpileAndWrite() { | ||
try { | ||
const fileContent = readFileSync(fileName, "utf-8"); | ||
const structype = toStructypeSchema(fileContent); | ||
const serialized = serializeSchemas(structype); | ||
const fileContent = (0, import_fs.readFileSync)(fileName, "utf-8"); | ||
const structype = (0, import_vgql_structype_graphql.toStructypeSchema)(fileContent); | ||
const serialized = (0, import_vgql_structype.serializeSchemas)(structype); | ||
const formatted = await format(serialized); | ||
writeFileSync(options.out, formatted, "utf-8"); | ||
(0, import_fs.writeFileSync)(options.out, formatted, "utf-8"); | ||
console.log( | ||
@@ -34,8 +70,45 @@ `>> Successfully transpiled GraphQL to Structype (${options.out})` | ||
if (options.watch) { | ||
watchFile(fileName, { interval: 200 }, transpileAndWrite); | ||
(0, import_fs.watchFile)(fileName, { interval: 200 }, transpileAndWrite); | ||
} | ||
}); | ||
program.parse(); | ||
export { | ||
import_extra_typings.program.command("start <file>").requiredOption("-s, --state <path>", "state path").requiredOption("-o, --out <path>", "output path").option("-p, --port <port>", "port number", "4237").description("Run VGQL Server").action((fileName, options) => { | ||
const statePath = options.state; | ||
let closeServerIfExists = () => { | ||
}; | ||
async function runServerAndTranspileSchema() { | ||
try { | ||
closeServerIfExists(); | ||
const resolvedStatePath = require.resolve((0, import_path.join)(process.cwd(), statePath)); | ||
delete require.cache[resolvedStatePath]; | ||
const stateContent = require(resolvedStatePath); | ||
const fileContent = (0, import_fs.readFileSync)(fileName, "utf-8"); | ||
const structype = (0, import_vgql_structype_graphql.toStructypeSchema)(fileContent); | ||
const serialized = (0, import_vgql_structype.serializeSchemas)(structype); | ||
const formatted = await format(serialized); | ||
(0, import_fs.writeFileSync)(options.out, formatted, "utf-8"); | ||
console.log( | ||
`>> Successfully transpiled GraphQL to Structype (${options.out})` | ||
); | ||
console.log(`>> Starting VGQL Server`); | ||
const server = await (0, import_vgql_core.VirtualHttpServer)( | ||
structype, | ||
fileContent, | ||
stateContent.default, | ||
parseInt(options.port) | ||
); | ||
closeServerIfExists = server.close; | ||
console.log(`>> Server running on port ${server.port}`); | ||
} catch (error) { | ||
console.log(`>> Error`); | ||
console.error(error); | ||
} | ||
} | ||
(0, import_fs.watchFile)(options.state, { interval: 200 }, runServerAndTranspileSchema); | ||
(0, import_fs.watchFile)(fileName, { interval: 200 }, runServerAndTranspileSchema); | ||
runServerAndTranspileSchema(); | ||
}); | ||
import_extra_typings.program.parse(); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
format | ||
}; | ||
}); |
{ | ||
"name": "@kube/vgql-cli", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"author": "Chris Feijoo", | ||
"license": "MIT", | ||
"type": "module", | ||
"bin": "dist/cli.js", | ||
@@ -12,4 +11,5 @@ "dependencies": { | ||
"prettier": "^3.2.1", | ||
"@kube/vgql-structype-graphql": "0.0.1", | ||
"@kube/vgql-structype": "0.0.1" | ||
"@kube/vgql-core": "0.0.3", | ||
"@kube/vgql-structype-graphql": "0.0.3", | ||
"@kube/vgql-structype": "0.0.3" | ||
}, | ||
@@ -22,4 +22,4 @@ "devDependencies": { | ||
"scripts": { | ||
"build": "tsup src/cli.ts --format=esm" | ||
"build": "tsup src/cli.ts --format=cjs" | ||
} | ||
} |
import { program } from "@commander-js/extra-typings"; | ||
import { join } from "path"; | ||
import { VirtualHttpServer } from "@kube/vgql-core"; | ||
import { serializeSchemas } from "@kube/vgql-structype"; | ||
@@ -47,2 +50,53 @@ import { toStructypeSchema } from "@kube/vgql-structype-graphql"; | ||
program | ||
.command("start <file>") | ||
.requiredOption("-s, --state <path>", "state path") | ||
.requiredOption("-o, --out <path>", "output path") | ||
.option("-p, --port <port>", "port number", "4237") | ||
.description("Run VGQL Server") | ||
.action((fileName, options) => { | ||
const statePath = options.state; | ||
let closeServerIfExists = () => {}; | ||
async function runServerAndTranspileSchema() { | ||
try { | ||
closeServerIfExists(); | ||
const resolvedStatePath = require.resolve( | ||
join(process.cwd(), statePath) | ||
); | ||
// FRESH LOAD OF STATE | ||
delete require.cache[resolvedStatePath]; | ||
const stateContent = require(resolvedStatePath); | ||
const fileContent = readFileSync(fileName, "utf-8"); | ||
const structype = toStructypeSchema(fileContent); | ||
const serialized = serializeSchemas(structype); | ||
const formatted = await format(serialized); | ||
writeFileSync(options.out, formatted, "utf-8"); | ||
console.log( | ||
`>> Successfully transpiled GraphQL to Structype (${options.out})` | ||
); | ||
console.log(`>> Starting VGQL Server`); | ||
const server = await VirtualHttpServer( | ||
structype, | ||
fileContent, | ||
stateContent.default, | ||
parseInt(options.port) | ||
); | ||
closeServerIfExists = server.close; | ||
console.log(`>> Server running on port ${server.port}`); | ||
} catch (error) { | ||
console.log(`>> Error`); | ||
console.error(error); | ||
} | ||
} | ||
watchFile(options.state, { interval: 200 }, runServerAndTranspileSchema); | ||
watchFile(fileName, { interval: 200 }, runServerAndTranspileSchema); | ||
runServerAndTranspileSchema(); | ||
}); | ||
program.parse(); |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
181852
8
449
6
11
2
No
+ Added@kube/vgql-core@0.0.3
+ Added@graphql-tools/merge@9.0.10(transitive)
+ Added@graphql-tools/schema@10.0.9(transitive)
+ Added@graphql-tools/utils@10.6.0(transitive)
+ Added@graphql-typed-document-node/core@3.2.0(transitive)
+ Added@kube/vgql-core@0.0.3(transitive)
+ Added@kube/vgql-hkt@0.0.3(transitive)
+ Added@kube/vgql-structype@0.0.3(transitive)
+ Added@kube/vgql-structype-graphql@0.0.3(transitive)
+ Addedaccepts@1.3.8(transitive)
+ Addedarray-flatten@1.1.1(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.7.1(transitive)
+ Addedcookie-signature@1.0.6(transitive)
+ Addedcross-inspect@1.0.1(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddset@3.1.4(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.22.0.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@4.21.1(transitive)
+ Addedfinalhandler@1.3.1(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmerge-descriptors@1.0.3(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@0.1.10(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsend@0.19.0(transitive)
+ Addedserve-static@1.16.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addeduuid@9.0.1(transitive)
+ Addedvalue-or-promise@1.0.12(transitive)
+ Addedvary@1.1.2(transitive)
- Removed@kube/vgql-hkt@0.0.1(transitive)
- Removed@kube/vgql-structype@0.0.1(transitive)
- Removed@kube/vgql-structype-graphql@0.0.1(transitive)
Updated@kube/vgql-structype@0.0.3