console/integration-tests/testkit/cli.ts
2022-12-28 20:22:54 +01:00

32 lines
886 B
TypeScript

import { resolve } from 'path';
import { execaCommand } from '@esm2cjs/execa';
import { getServiceHost } from './utils';
const binPath = resolve(__dirname, '../../packages/libraries/cli/bin/dev');
async function exec(cmd: string) {
const outout = await execaCommand(`${binPath} ${cmd}`, {
shell: true,
});
if (outout.failed) {
throw new Error(outout.stderr);
}
return outout.stdout;
}
export async function schemaPublish(args: string[]) {
const registryAddress = await getServiceHost('server', 8082);
return await exec(
['schema:publish', `--registry`, `http://${registryAddress}/graphql`, ...args].join(' '),
);
}
export async function schemaCheck(args: string[]) {
const registryAddress = await getServiceHost('server', 8082);
return await exec(
['schema:check', `--registry`, `http://${registryAddress}/graphql`, ...args].join(' '),
);
}