move codegen configs from yaml to toml

This commit is contained in:
Laura Liberda 2021-02-01 15:18:02 +01:00
parent 20b1bec866
commit 5f24ff76c4
7 changed files with 26 additions and 26 deletions

View file

@ -63,7 +63,6 @@
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"js-yaml": "^3.14.0",
"prettier": "^2.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"

View file

@ -7,17 +7,17 @@
*/
import { generate } from '@graphql-codegen/cli';
import { safeLoad as yamlLoad } from 'js-yaml';
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.yml')));
const gqlVendors = vendors.filter((v) => existsSync(path.join(vendorPath, v, 'codegen.toml')));
Promise.all(
gqlVendors
.map((v) => path.join(vendorPath, v, 'codegen.yml'))
.map((v) => path.join(vendorPath, v, 'codegen.toml'))
.map((codegenFile) =>
generate(yamlLoad(readFileSync(codegenFile).toString('utf-8')) as any, true),
generate(TOML.parse(readFileSync(codegenFile).toString('utf-8')) as any, true),
),
).then(() => console.log('done!'));

10
src/vendor/github/codegen.toml vendored Normal file
View file

@ -0,0 +1,10 @@
overwrite = true
schema = 'src/vendor/github/schema.graphql'
[config]
typesPrefix = 'GH'
[generates.'src/vendor/github/api-types.ts']
plugins = [
'typescript',
]

View file

@ -1,9 +0,0 @@
overwrite: true
schema: src/vendor/github/schema.graphql
config:
typesPrefix: GH
generates:
src/vendor/github/api-types.ts:
plugins:
- 'typescript'
- 'typescript-resolvers'

11
src/vendor/gitlab/codegen.toml vendored Normal file
View file

@ -0,0 +1,11 @@
overwrite = true
schema= 'src/vendor/gitlab/schema.graphql'
[config]
typesPrefix = 'GL'
namingConvention = { enumValues = 'keep' }
[generates.'src/vendor/gitlab/api-types.ts']
plugins = [
'typescript',
]

View file

@ -1,11 +0,0 @@
overwrite: true
schema: src/vendor/gitlab/schema.graphql
config:
typesPrefix: GL
namingConvention:
# https://github.com/dotansimha/graphql-code-generator/issues/642#issuecomment-495919863
enumValues: keep
generates:
src/vendor/gitlab/api-types.ts:
plugins:
- 'typescript'

View file

@ -3015,7 +3015,7 @@ iterall@^1.2.1:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
js-yaml@^3.10.0, js-yaml@^3.13.1, js-yaml@^3.14.0:
js-yaml@^3.10.0, js-yaml@^3.13.1:
version "3.14.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482"
integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==