Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kube/vgql-cli

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kube/vgql-cli - npm Package Compare versions

Comparing version 0.0.1 to 0.0.3

dist/chunk-KTNJQ3XE.js

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
};
});

10

package.json
{
"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();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc