24 lines
963 B
TypeScript
24 lines
963 B
TypeScript
/*
|
|
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
|
*
|
|
* This is free software, and you are welcome to redistribute it
|
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
|
* or, if the file is unavailable, visit <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
|
*/
|
|
|
|
import { generate } from '@graphql-codegen/cli';
|
|
import TOML from '@iarna/toml';
|
|
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.toml')));
|
|
Promise.all(
|
|
gqlVendors
|
|
.map((v) => path.join(vendorPath, v, 'codegen.toml'))
|
|
.map((codegenFile) =>
|
|
generate(TOML.parse(readFileSync(codegenFile).toString('utf-8')) as any, true),
|
|
),
|
|
).then(() => console.log('done!'));
|