mirror of
https://github.com/graphql-hive/console
synced 2026-05-24 09:38:26 +00:00
32 lines
886 B
TypeScript
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(' '),
|
|
);
|
|
}
|