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

gql-types-generator

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql-types-generator - npm Package Compare versions

Comparing version 1.2.6 to 1.2.8

2

dist/cli.js

@@ -73,3 +73,3 @@ #!/usr/bin/env node

if (!operations) return [3 /*break*/, 2];
return [4 /*yield*/, fs_1.withCwdAndGlob(operations)];
return [4 /*yield*/, fs_1.withCwdAndGlob(operations.split(','))];
case 1:

@@ -76,0 +76,0 @@ _c = _d.sent();

@@ -52,5 +52,5 @@ "use strict";

// flattenOperations = false,
outputDirectory, _a, display, _b, removeDescription, includeDescription, schemaString, schema, operationsString, _c;
return __generator(this, function (_d) {
switch (_d.label) {
outputDirectory, _a, display, _b, removeDescription, includeDescription, schemaString, _c, cwd, globs, _d, schema, operationsString, _e;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:

@@ -63,8 +63,17 @@ operationsPath = options.operationsPath, outputDirectory = options.outputDirectory, _a = options.display, display = _a === void 0 ? 'default' : _a, _b = options.removeDescription, removeDescription = _b === void 0 ? false : _b;

case 1:
schemaString = _d.sent();
return [3 /*break*/, 3];
schemaString = _f.sent();
return [3 /*break*/, 6];
case 2:
if (!('schema' in options)) return [3 /*break*/, 3];
schemaString = options.schema;
_d.label = 3;
return [3 /*break*/, 6];
case 3:
_c = options.schemaGlobs, cwd = _c.cwd, globs = _c.globs;
_d = fs_1.getFileContent;
return [4 /*yield*/, fs_1.withCwdAndGlob(globs, cwd)];
case 4: return [4 /*yield*/, _d.apply(void 0, [_f.sent()])];
case 5:
schemaString = _f.sent();
_f.label = 6;
case 6:
console.log(chalk_1.yellow('Starting compilation with options:'), {

@@ -81,12 +90,12 @@ operationsPath: operationsPath,

schema = compileSchema(schemaString, outputDirectory, includeDescription, display).schema;
if (!operationsPath) return [3 /*break*/, 5];
if (!operationsPath) return [3 /*break*/, 8];
return [4 /*yield*/, fs_1.getFileContent(operationsPath)];
case 4:
_c = _d.sent();
return [3 /*break*/, 6];
case 5:
_c = null;
_d.label = 6;
case 6:
operationsString = _c;
case 7:
_e = _f.sent();
return [3 /*break*/, 9];
case 8:
_e = null;
_f.label = 9;
case 9:
operationsString = _e;
if (typeof operationsString === 'string') {

@@ -93,0 +102,0 @@ if (operationsString.length === 0) {

/**
* Adds current working directory to path
* @param {string} path
* @param cwd
* @returns {string}
*/
export declare function withCwd(path: string): string;
export declare function withCwd(path: string, cwd?: string): string;
/**
* Returns paths to files which compares passed pattern
* @param {string} pattern
* @returns {Promise<string[]>}
* @param globs
* @param cwd
*/
export declare function withCwdAndGlob(pattern: string): Promise<string[]>;
export declare function withCwdAndGlob(globs: string | string[], cwd?: string): Promise<string[]>;
/**

@@ -14,0 +16,0 @@ * Returns content of files found with passed glob or globs

@@ -53,9 +53,10 @@ "use strict";

var shell = __importStar(require("shelljs"));
var cwd = process.cwd();
/**
* Adds current working directory to path
* @param {string} path
* @param cwd
* @returns {string}
*/
function withCwd(path) {
function withCwd(path, cwd) {
if (cwd === void 0) { cwd = process.cwd(); }
return path.startsWith('/')

@@ -68,12 +69,15 @@ ? cwd + path

* Returns paths to files which compares passed pattern
* @param {string} pattern
* @returns {Promise<string[]>}
* @param globs
* @param cwd
*/
function withCwdAndGlob(pattern) {
function withCwdAndGlob(globs, cwd) {
if (cwd === void 0) { cwd = process.cwd(); }
return __awaiter(this, void 0, void 0, function () {
var patterns, matches;
var formattedGlobs, patterns, matches;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
patterns = pattern.split(',').map(withCwd);
formattedGlobs = Array.isArray(globs) ? globs : [globs];
patterns = formattedGlobs.map(function (g) { return withCwd(g, cwd); });
return [4 /*yield*/, Promise.all(patterns.map(function (p) { return new Promise(function (res, rej) {

@@ -125,3 +129,3 @@ glob_1.default(p, function (err, matches) {

contents = _a.sent();
return [2 /*return*/, contents.reduce(function (acc, c) { return acc + c; })];
return [2 /*return*/, contents.reduce(function (acc, c) { return acc + c; }, '')];
}

@@ -128,0 +132,0 @@ });

@@ -45,5 +45,14 @@ /**

/**
* Compile function options which takes glob
*/
export interface CompileGlob extends CompileOptionsShared {
schemaGlobs: {
cwd: string;
globs: string | string[];
};
}
/**
* Possible compile options
*/
export declare type CompileOptions = CompileFileOptions | CompileTextOptions;
export declare type CompileOptions = CompileFileOptions | CompileTextOptions | CompileGlob;
/**

@@ -50,0 +59,0 @@ * Represents compiled operation

{
"name": "gql-types-generator",
"version": "1.2.6",
"version": "1.2.8",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -67,4 +67,4 @@ gql-types-generator

schemaPath: [
path.resolve(__dirname, 'schema-artifacts-folder-1/*.graphql'),
path.resolve(__dirname, 'schema-artifacts-folder-2/*.graphql')
path.resolve(__dirname, 'schema-artifacts-folder-1/schema-part.graphql'),
path.resolve(__dirname, 'schema-artifacts-folder-2/schema-part.graphql')
],

@@ -78,3 +78,3 @@ outputDirectory: path.resolve(__dirname, 'compiled'),

compile({
schemaPath: path.resolve(__dirname, 'schema-artifacts/*.graphql'),
schemaPath: path.resolve(__dirname, 'schema-artifacts/schema.graphql'),
outputDirectory: path.resolve(__dirname, 'compiled'),

@@ -101,1 +101,13 @@ });

```
Getting schema partials with globs or glob
```typescript
compile({
schemaGlobs: {
cwd: process.cwd(),
globs: '/schema-artifacts/*.graphql',
},
outputDirectory: path.resolve(__dirname, 'compiled'),
sort: 'as-is'
});
```
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