Skip to content

fix project config #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"dependencyDashboard": false,
"onboarding": false,
"prConcurrentLimit": 5
}
}
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: current
cache: 'pnpm'
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm test
env:
Expand All @@ -32,10 +32,9 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: current
cache: 'pnpm'
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint-fix
- run: pnpm prettier
- name: Auto commit fixed code
id: auto-commit-action
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issues.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'good first issue'
name: good first issue
on: [issues]

jobs:
Expand Down
9 changes: 1 addition & 8 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
node_modules
dist
.npmignore
package-lock.json
.DS_Store
tsconfig.tsbuildinfo
example
vitest.config.ts
**
6 changes: 0 additions & 6 deletions .prettierrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ generates:
constraint:
minLength: min
# Replace $1 with specified `startsWith` argument value of the constraint directive
startsWith: ["matches", "/^$1/"]
startsWith: [matches, /^$1/]
format:
email: email
```
Expand All @@ -249,7 +249,7 @@ Then generates yup validation schema like below.
```ts
export function ExampleInputSchema(): yup.SchemaOf<ExampleInput> {
return yup.object({
email: yup.string().defined().required("Hello, World!").min(50).email(),
email: yup.string().defined().required('Hello, World!').min(50).email(),
message: yup.string().defined().matches(/^Hello/)
})
}
Expand Down Expand Up @@ -277,7 +277,7 @@ generates:
constraint:
minLength: min
# Replace $1 with specified `startsWith` argument value of the constraint directive
startsWith: ["regex", "/^$1/", "message"]
startsWith: [regex, /^$1/, message]
format:
email: email
```
Expand All @@ -288,7 +288,7 @@ Then generates zod validation schema like below.
export function ExampleInputSchema(): z.ZodSchema<ExampleInput> {
return z.object({
email: z.string().min(50).email(),
message: z.string().regex(/^Hello/, "message")
message: z.string().regex(/^Hello/, 'message')
})
}
```
Expand All @@ -310,4 +310,4 @@ generates:
preset: 'client',
plugins:
...
```
```
20 changes: 10 additions & 10 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
overwrite: true
schema: './example/test.graphql'
schema: ./example/test.graphql
generates:
example/types.ts:
plugins:
Expand All @@ -21,11 +21,11 @@ generates:
constraint:
minLength: min # same as ['min', '$1']
maxLength: max
startsWith: ['matches', '/^$1/']
endsWith: ['matches', '/$1$/']
contains: ['matches', '/$1/']
notContains: ['matches', '/^((?!$1).)*$/']
pattern: ['matches', '/$1/']
startsWith: [matches, /^$1/]
endsWith: [matches, /$1$/]
contains: [matches, /$1/]
notContains: [matches, '/^((?!$1).)*$/']
pattern: [matches, /$1/]
format:
# For example, `@constraint(format: "uri")`. this case $1 will be "uri".
# Therefore the generator generates yup schema `.url()` followed by `uri: 'url'`
Expand All @@ -37,8 +37,8 @@ generates:
# you need to add the logic using `yup.addMethod`.
# see: https://github.com/jquense/yup#addmethodschematype-schema-name-string-method--schema-void
ipv4: ipv4
min: ['min', '$1 - 1']
max: ['max', '$1 + 1']
min: [min, $1 - 1]
max: [max, '$1 + 1']
exclusiveMin: min
exclusiveMax: max
scalars:
Expand All @@ -61,7 +61,7 @@ generates:
constraint:
minLength: min
# Replace $1 with specified `startsWith` argument value of the constraint directive
startsWith: ['regex', '/^$1/', 'message']
startsWith: [regex, /^$1/, message]
format:
email: email
scalars:
Expand All @@ -76,7 +76,7 @@ generates:
constraint:
minLength: min
# Replace $1 with specified `startsWith` argument value of the constraint directive
startsWith: ['pattern', '/^$1/']
startsWith: [pattern, /^$1/]
format:
email: email
scalars:
Expand Down
16 changes: 16 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import antfu from '@antfu/eslint-config'

export default antfu({
typescript: true,
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
ignores: [
'dist/**',
'node_modules/**',
'example/**',
'vitest.config.ts',
'tsconfig.json',
'README.md',
],
}, {
rules: { 'style/semi': 'off' },
})
92 changes: 47 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,10 @@
"type": "git",
"url": "https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema.git"
},
"main": "dist/main/index.js",
"typings": "dist/main/index.d.ts",
"module": "dist/module/index.js",
"files": [
"dist/**/*.{js,ts}",
"LICENSE",
"README.md"
],
"scripts": {
"type-check": "tsc --noEmit",
"type-check:yup": "tsc --strict --noEmit example/yup/schemas.ts",
"type-check:zod": "tsc --strict --noEmit example/zod/schemas.ts",
"type-check:myzod": "tsc --strict --noEmit example/myzod/schemas.ts",
"test": "vitest run",
"build": "run-p build:*",
"build:main": "tsc -p tsconfig.main.json",
"build:module": "tsc -p tsconfig.module.json",
"lint": "eslint --ext .ts .",
"lint-fix": "eslint --fix --ext .ts .",
"prettier": "prettier --write --list-different \"**/*.{ts,graphql,yml}\"",
"prettier:check": "prettier --check \"**/*.{ts,graphql,yml}\"",
"generate": "run-p build:* && graphql-codegen",
"prepublish": "run-p build:*"
"author": "codehex",
"license": "MIT",
"bugs": {
"url": "https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/issues"
},
"keywords": [
"gql",
Expand All @@ -44,43 +25,64 @@
"types",
"typings"
],
"author": "codehex",
"license": "MIT",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/module/index.js",
"require": "./dist/main/index.js"
}
},
"main": "dist/main/index.js",
"typings": "dist/types/index.d.ts",
"module": "dist/module/index.js",
"files": [
"!dist/**/*.tsbuildinfo",
"LICENSE",
"README.md",
"dist/**/*.{js,ts}"
],
"scripts": {
"type-check": "tsc --noEmit",
"type-check:yup": "tsc --strict --skipLibCheck --noEmit example/yup/schemas.ts",
"type-check:zod": "tsc --strict --skipLibCheck --noEmit example/zod/schemas.ts",
"type-check:myzod": "tsc --strict --skipLibCheck --noEmit example/myzod/schemas.ts",
"test": "vitest run",
"build": "run-p build:*",
"build:main": "tsc -p tsconfig.main.json",
"build:module": "tsc -p tsconfig.module.json",
"build:types": "tsc -p tsconfig.types.json",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"generate": "run-p build:* && graphql-codegen",
"prepublish": "run-p build:*"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^5.0.0",
"@graphql-codegen/schema-ast": "4.0.2",
"@graphql-codegen/visitor-plugin-common": "^5.0.0",
"@graphql-tools/utils": "^10.0.0",
"graphlib": "^2.1.8",
"graphql": "^16.6.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.12.2",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/typescript": "^4.0.0",
"@tsconfig/recommended": "1.0.6",
"@types/graphlib": "^2.1.8",
"@types/jest": "29.5.12",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "7.5.0",
"@typescript-eslint/parser": "7.5.0",
"eslint": "9.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "29.7.0",
"myzod": "1.11.0",
"npm-run-all2": "6.1.2",
"prettier": "3.2.5",
"ts-dedent": "^2.2.0",
"ts-jest": "29.1.2",
"typescript": "5.4.4",
"vitest": "^1.0.0",
"yup": "1.4.0",
"zod": "3.22.4"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^5.0.0",
"@graphql-codegen/schema-ast": "4.0.2",
"@graphql-codegen/visitor-plugin-common": "^5.0.0",
"@graphql-tools/utils": "^10.0.0",
"graphlib": "^2.1.8",
"graphql": "^16.6.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
},
"bugs": {
"url": "https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/issues"
}
}
Loading