Skip to content

Commit 492fb70

Browse files
committed
Merge branch 'refs/heads/main' into improve-query-type-handling
# Conflicts: # src/annotations/build-description-annotation.ts # src/config/build-config-with-defaults.ts # src/config/find-type-in-resolver-interfaces-config.ts # src/definitions/object.ts
2 parents c9311c8 + ff1811a commit 492fb70

File tree

9 files changed

+99
-4
lines changed

9 files changed

+99
-4
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun lint && bun format && git add .
1+
bun lint:fix && bun format && git add .

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export default [
2020
},
2121
},
2222
{
23-
ignores: ["build", "dist", "docs"],
23+
ignores: ["build", "dist", "docs", "scripts"],
2424
},
2525
];

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"format": "prettier --write .",
4444
"format-check": "prettier --check .",
4545
"integration": "bun run build && graphql-codegen && ./gradlew graphqlGenerateSDL && bun test ./test/integration.test.ts",
46-
"lint": "eslint .",
46+
"lint": "bun ./scripts/check-headers.ts && eslint .",
47+
"lint:fix": "bun ./scripts/fix-headers.ts && eslint --fix .",
4748
"prepack": "bun run build",
4849
"prepare": "husky",
4950
"unit": "bun test ./test/plugin.test.ts"

scripts/check-headers.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Glob } from "bun";
2+
3+
const filePaths = new Glob("src/**/*.ts").scan();
4+
5+
let filesWithoutCopyrightHeader: string[] = [];
6+
for await (const filePath of filePaths) {
7+
const fileContents = await Bun.file(filePath).text();
8+
if (!fileContents.startsWith("/*\nCopyright")) {
9+
filesWithoutCopyrightHeader.push(filePath);
10+
}
11+
}
12+
13+
if (filesWithoutCopyrightHeader.length) {
14+
console.error(
15+
`\nThe following files are missing a valid copyright header:${filesWithoutCopyrightHeader.map((file) => `\n • ${file}`).join()}`,
16+
);
17+
process.exit(1);
18+
}

scripts/fix-headers.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Glob } from "bun";
2+
3+
const copyrightHeader = `/*
4+
Copyright 2024 Expedia, Inc.
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
`;
17+
18+
const filePaths = new Glob("src/**/*.ts").scan();
19+
for await (const filePath of filePaths) {
20+
const fileContents = await Bun.file(filePath).text();
21+
if (!fileContents.startsWith("/*\nCopyright")) {
22+
await Bun.write(filePath, `${copyrightHeader}${fileContents}`);
23+
}
24+
}

src/annotations/build-description-annotation.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
Copyright 2024 Expedia, Inc.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
https://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
114
import { CodegenConfigWithDefaults } from "../config/build-config-with-defaults";
215
import { TypeMetadata } from "../utils/build-type-metadata";
316
import { indent } from "@graphql-codegen/visitor-plugin-common";

src/config/build-config-with-defaults.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
Copyright 2024 Expedia, Inc.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
https://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
114
import { GraphQLKotlinCodegenConfig } from "../plugin";
215
import { buildPackageNameFromPath } from "@graphql-codegen/java-common";
316
import { dirname, normalize } from "path";

src/config/find-type-in-resolver-interfaces-config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
/*
2+
Copyright 2024 Expedia, Inc.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
https://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
114
import { InterfaceTypeDefinitionNode, ObjectTypeDefinitionNode } from "graphql";
2-
import { CodegenConfigWithDefaults } from "../config/build-config-with-defaults";
15+
import { CodegenConfigWithDefaults } from "./build-config-with-defaults";
316

417
export function findTypeInResolverInterfacesConfig(
518
node: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode,

src/utils/input-type-has-matching-output-type.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
Copyright 2024 Expedia, Inc.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
https://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
114
import {
215
GraphQLSchema,
316
InputObjectTypeDefinitionNode,

0 commit comments

Comments
 (0)