diff --git a/package.json b/package.json index a862321..d3fe9a0 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/scripts/generate-gql-types.ts b/scripts/generate-gql-types.ts index b15665f..6ab7a09 100644 --- a/scripts/generate-gql-types.ts +++ b/scripts/generate-gql-types.ts @@ -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!')); diff --git a/src/vendor/github/codegen.toml b/src/vendor/github/codegen.toml new file mode 100644 index 0000000..3168eb3 --- /dev/null +++ b/src/vendor/github/codegen.toml @@ -0,0 +1,10 @@ +overwrite = true +schema = 'src/vendor/github/schema.graphql' + +[config] + typesPrefix = 'GH' + +[generates.'src/vendor/github/api-types.ts'] + plugins = [ + 'typescript', + ] diff --git a/src/vendor/github/codegen.yml b/src/vendor/github/codegen.yml deleted file mode 100644 index d167e4b..0000000 --- a/src/vendor/github/codegen.yml +++ /dev/null @@ -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' diff --git a/src/vendor/gitlab/codegen.toml b/src/vendor/gitlab/codegen.toml new file mode 100644 index 0000000..70e6ff0 --- /dev/null +++ b/src/vendor/gitlab/codegen.toml @@ -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', + ] diff --git a/src/vendor/gitlab/codegen.yml b/src/vendor/gitlab/codegen.yml deleted file mode 100644 index 1f884a3..0000000 --- a/src/vendor/gitlab/codegen.yml +++ /dev/null @@ -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' diff --git a/yarn.lock b/yarn.lock index 8ff3f6f..6dbdd41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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==