Skip to content

Commit ff1811a

Browse files
authored
refactor: reorganize repo (#75)
* unit test * refactor * pass test * add mutation tests * fix integration test * refactor * reorganize * separate field definition functions * pull out boolean arg * pull out other boolean arg * refactor * refactor * bun version * set up docs workspace * undo * fix copywright headers
1 parent 11097d5 commit ff1811a

34 files changed

+602
-392
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ jobs:
3838

3939
- name: Integration Test
4040
run: bun integration
41+
42+
- name: Build Docs
43+
run: bun docs:build

.github/workflows/docs.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,8 @@ jobs:
3131
- name: Install Dependencies
3232
run: bun install
3333

34-
- name: Build Plugin
35-
run: bun run build
36-
37-
- name: Install Docs Dependencies
38-
run: bun install
39-
working-directory: docs
40-
4134
- name: Build Docs
4235
run: bun docs:build
43-
working-directory: docs
4436

4537
- name: Setup Pages
4638
uses: actions/configure-pages@v5

.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 .

bun.lockb

373 KB
Binary file not shown.

docs/bun.lockb

-472 KB
Binary file not shown.

docs/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "docs",
33
"private": true,
44
"scripts": {
5-
"docs:start": "docusaurus start",
6-
"docs:build": "tsc && bun generate && docusaurus build",
7-
"generate": "jsdoc2md --files ../dist/plugin.cjs --partial partials/main.hbs --partial partials/scope.hbs -c jsdoc.conf > docs/configuration.md"
5+
"build": "tsc && bun generate && docusaurus build",
6+
"generate": "jsdoc2md --files ../dist/plugin.cjs --partial partials/main.hbs --partial partials/scope.hbs -c jsdoc.conf > docs/configuration.md",
7+
"start": "docusaurus start"
88
},
99
"devDependencies": {
1010
"@docusaurus/core": "3.3.2",
@@ -13,6 +13,7 @@
1313
"@docusaurus/tsconfig": "3.3.2",
1414
"@docusaurus/types": "3.3.2",
1515
"@mdx-js/react": "3.0.1",
16+
"ajv": "8.14.0",
1617
"clsx": "2.1.1",
1718
"jsdoc-to-markdown": "8.0.1",
1819
"prism-react-renderer": "2.3.1",

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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@expediagroup/graphql-kotlin-codegen",
3-
"packageManager": "[email protected].6",
3+
"packageManager": "[email protected].10",
44
"main": "dist/plugin.cjs",
55
"types": "dist/plugin.d.cts",
66
"files": [
@@ -22,6 +22,7 @@
2222
"@graphql-codegen/java-common": "3.0.0",
2323
"@graphql-codegen/plugin-helpers": "5.0.4",
2424
"@graphql-codegen/visitor-plugin-common": "5.2.0",
25+
"ts-deepmerge": "7.0.0",
2526
"valibot": "0.30.0"
2627
},
2728
"devDependencies": {
@@ -37,13 +38,19 @@
3738
},
3839
"scripts": {
3940
"build": "tsup src/plugin.ts --clean --dts --external graphql",
41+
"docs:build": "bun run build && bun --filter docs build",
42+
"docs:start": "bun --filter docs start",
4043
"format": "prettier --write .",
4144
"format-check": "prettier --check .",
4245
"integration": "bun run build && graphql-codegen && ./gradlew graphqlGenerateSDL && bun test ./test/integration.test.ts",
43-
"lint": "eslint .",
46+
"lint": "bun ./scripts/check-headers.ts && eslint .",
47+
"lint:fix": "bun ./scripts/fix-headers.ts && eslint --fix .",
4448
"prepack": "bun run build",
4549
"prepare": "husky",
4650
"unit": "bun test ./test/plugin.test.ts"
4751
},
48-
"type": "module"
52+
"type": "module",
53+
"workspaces": [
54+
"docs"
55+
]
4956
}

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+
}

0 commit comments

Comments
 (0)