@graphql-inspector/commands
Advanced tools
Comparing version 0.0.0-canary.8127707 to 0.0.0-canary.02a53c5
@@ -26,2 +26,4 @@ 'use strict'; | ||
const headers = {}; | ||
const leftHeaders = {}; | ||
const rightHeaders = {}; | ||
if (args.header) { | ||
@@ -33,6 +35,18 @@ args.header.forEach((header) => { | ||
} | ||
if (args.leftHeader) { | ||
args.leftHeader.forEach((leftHeader) => { | ||
const [lname, ...lvalues] = leftHeader.split(':'); | ||
leftHeaders[lname] = lvalues.join(''); | ||
}); | ||
} | ||
if (args.rightHeader) { | ||
args.rightHeader.forEach((rightHeader) => { | ||
const [rname, ...rvalues] = rightHeader.split(':'); | ||
rightHeaders[rname] = rvalues.join(''); | ||
}); | ||
} | ||
if (args.require) { | ||
args.require.forEach((mod) => require(mod)); | ||
} | ||
return { headers, token: args.token }; | ||
return { headers, leftHeaders, rightHeaders, token: args.token }; | ||
} | ||
@@ -39,0 +53,0 @@ function mockCommand(mod, cmd) { |
import { InspectorConfig } from '@graphql-inspector/config'; | ||
import { Loaders } from '@graphql-inspector/loaders'; | ||
import { CommandModule } from 'yargs'; | ||
export { CommandModule as Command }; | ||
import { CommandModule as Command } from 'yargs'; | ||
export { Command }; | ||
export interface UseCommandsAPI { | ||
config: InspectorConfig; | ||
loaders: Loaders; | ||
intercept?<T>(args: T): Promise<T>; | ||
} | ||
export declare type CommandFactory<T = {}, U = {}> = (api: UseCommandsAPI) => CommandModule<T, U>; | ||
export declare function useCommands(api: UseCommandsAPI): CommandModule[]; | ||
export declare type CommandFactory<T = {}, U = {}> = (api: Required<UseCommandsAPI>) => Command<T, U>; | ||
export declare function useCommands(api: UseCommandsAPI): Command[]; | ||
export declare function createCommand<T = {}, U = {}>(factory: CommandFactory<T, U>): CommandFactory<T, U>; | ||
@@ -18,7 +17,14 @@ export declare function ensureAbsolute(filepath: string, basepath?: string): string; | ||
header?: string[]; | ||
leftHeader?: string[]; | ||
rightHeader?: string[]; | ||
federation?: boolean; | ||
aws?: boolean; | ||
method?: string; | ||
} | ||
export declare function parseGlobalArgs(args: GlobalArgs): { | ||
headers: Record<string, string>; | ||
leftHeaders: Record<string, string>; | ||
rightHeaders: Record<string, string>; | ||
token: string | undefined; | ||
}; | ||
export declare function mockCommand(mod: CommandModule, cmd: string): Promise<string>; | ||
export declare function mockCommand(mod: Command, cmd: string): Promise<string>; |
@@ -20,2 +20,4 @@ import { __awaiter } from 'tslib'; | ||
const headers = {}; | ||
const leftHeaders = {}; | ||
const rightHeaders = {}; | ||
if (args.header) { | ||
@@ -27,6 +29,18 @@ args.header.forEach((header) => { | ||
} | ||
if (args.leftHeader) { | ||
args.leftHeader.forEach((leftHeader) => { | ||
const [lname, ...lvalues] = leftHeader.split(':'); | ||
leftHeaders[lname] = lvalues.join(''); | ||
}); | ||
} | ||
if (args.rightHeader) { | ||
args.rightHeader.forEach((rightHeader) => { | ||
const [rname, ...rvalues] = rightHeader.split(':'); | ||
rightHeaders[rname] = rvalues.join(''); | ||
}); | ||
} | ||
if (args.require) { | ||
args.require.forEach((mod) => require(mod)); | ||
} | ||
return { headers, token: args.token }; | ||
return { headers, leftHeaders, rightHeaders, token: args.token }; | ||
} | ||
@@ -33,0 +47,0 @@ function mockCommand(mod, cmd) { |
{ | ||
"name": "@graphql-inspector/commands", | ||
"version": "0.0.0-canary.8127707", | ||
"version": "0.0.0-canary.02a53c5", | ||
"description": "Plugin system for commands in GraphQL Inspector", | ||
"sideEffects": false, | ||
"peerDependencies": { | ||
"@graphql-inspector/config": "0.0.0-canary.8127707", | ||
"@graphql-inspector/loaders": "0.0.0-canary.8127707", | ||
"@graphql-inspector/config": "0.0.0-canary.02a53c5", | ||
"@graphql-inspector/loaders": "0.0.0-canary.02a53c5", | ||
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0", | ||
"yargs": "15.3.1" | ||
"yargs": "17.0.1" | ||
}, | ||
@@ -12,0 +12,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14963
154
6