wgc
Version:
The official CLI tool to manage the GraphQL Federation Platform Cosmo
35 lines • 1.34 kB
JavaScript
import { PlatformService, } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { createClient as createConnectClient, createRouterTransport } from '@connectrpc/connect';
import { Command } from 'commander';
import RecomposeCommand from '../../src/commands/feature-flag/commands/recompose.js';
export function createMockTransport(response) {
return createRouterTransport(({ service }) => {
service(PlatformService, {
recomposeFeatureFlag: () => response,
});
});
}
export function createClient(response) {
return {
platform: createConnectClient(PlatformService, createMockTransport(response)),
};
}
export async function runRecompose(response, opts = {}) {
const args = ['recompose', 'feature-flag'];
if (opts.namespace) {
args.push('--namespace', opts.namespace);
}
if (opts.failOnCompositionError) {
args.push('--fail-on-composition-error');
}
if (opts.failOnAdmissionWebhookError) {
args.push('--fail-on-admission-webhook-error');
}
if (opts.suppressWarnings) {
args.push('--suppress-warnings');
}
const program = new Command();
program.addCommand(RecomposeCommand({ client: createClient(response) }));
await program.parseAsync(args, { from: 'user' });
}
//# sourceMappingURL=utils.js.map