16 lines
619 B
TypeScript
16 lines
619 B
TypeScript
import { generate } from '@graphql-codegen/cli';
|
|
import { safeLoad as yamlLoad } from 'js-yaml';
|
|
import { readdirSync, existsSync, readFileSync } from 'fs';
|
|
import path from 'path';
|
|
|
|
const vendorPath = path.join(__dirname, '..', 'src', 'vendor');
|
|
const vendors = readdirSync(vendorPath);
|
|
const gqlVendors = vendors.filter((v) => existsSync(path.join(vendorPath, v, 'codegen.yml')));
|
|
Promise.all(
|
|
gqlVendors
|
|
.map((v) => path.join(vendorPath, v, 'codegen.yml'))
|
|
.map((codegenFile) =>
|
|
generate(yamlLoad(readFileSync(codegenFile).toString('utf-8')) as any, true),
|
|
),
|
|
).then(() => console.log('done!'));
|