Skip to content

Commit a000b14

Browse files
authored
Update typescript setup (#74)
1 parent aefdd95 commit a000b14

16 files changed

Lines changed: 62 additions & 69 deletions

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"access": "public"
4949
},
5050
"scripts": {
51-
"build": "pnpm codegen:github && tsc --noEmit && tsdown",
51+
"build": "pnpm codegen:github && tsc && tsdown",
5252
"codegen:github": "graphql-codegen --config src/github/codegen.ts",
5353
"format": "oxfmt --check",
5454
"format:fix": "oxfmt",
@@ -66,6 +66,7 @@
6666
"@graphql-codegen/cli": "^7.0.0",
6767
"@octokit/core": "^6.1.2",
6868
"@octokit/graphql": "^8.1.1",
69+
"@tsconfig/node22": "^22.0.5",
6970
"@types/node": "^20.11.24",
7071
"dotenv": "^16.4.5",
7172
"oxfmt": "^0.51.0",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { GetRepositoryMetadataQuery } from "./github/graphql/generated/operations.js";
2-
import { CommitMessage } from "./github/graphql/generated/types.js";
2+
import type { CommitMessage } from "./github/graphql/generated/types.ts";
33
import {
44
createCommitOnBranchQuery,
55
getRepositoryMetadata,
6-
} from "./github/graphql/queries.js";
7-
import {
6+
} from "./github/graphql/queries.ts";
7+
import type {
88
CommitFilesFromBase64Args,
99
CommitFilesResult,
1010
GitBase,
11-
} from "./interface.js";
11+
} from "./interface.ts";
1212

1313
const getBaseRef = (base: GitBase): string => {
1414
if ("branch" in base) {

src/fs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { promises as fs } from "fs";
22
import * as path from "path";
3-
import type { FileAddition } from "./github/graphql/generated/types.js";
4-
import {
3+
import type { FileAddition } from "./github/graphql/generated/types.ts";
4+
import type {
55
CommitFilesFromDirectoryArgs,
66
CommitFilesResult,
7-
} from "./interface.js";
8-
import { commitFilesFromBuffers } from "./node.js";
7+
} from "./interface.ts";
8+
import { commitFilesFromBuffers } from "./node.ts";
99

1010
export const commitFilesFromDirectory = async ({
1111
cwd,

src/git.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { promises as fs } from "fs";
22
import { relative, resolve } from "path";
33
import git from "isomorphic-git";
4-
import {
4+
import type {
55
CommitChangesFromRepoArgs,
66
CommitFilesFromBuffersArgs,
77
CommitFilesResult,
8-
} from "./interface";
9-
import { commitFilesFromBuffers } from "./node";
8+
} from "./interface.ts";
9+
import { commitFilesFromBuffers } from "./node.ts";
1010

1111
/**
1212
* @see https://isomorphic-git.org/docs/en/walk#walkerentry-mode

src/github/codegen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const config: CodegenConfig = {
2626
config: {
2727
// TODO: Look into adding stricter types or use `unknown`
2828
defaultScalarType: "any",
29+
enumsAsTypes: true,
2930
},
3031
},
3132
"src/github/graphql/generated/operations.ts": {
@@ -34,6 +35,7 @@ const config: CodegenConfig = {
3435
// TODO: Look into adding stricter types or use `unknown`
3536
defaultScalarType: "any",
3637
importSchemaTypesFrom: "src/github/graphql/generated/types.ts",
38+
importExtension: ".ts",
3739
},
3840
},
3941
},

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * as queries from "./github/graphql/queries.js";
2-
export { commitFilesFromBase64 } from "./core.js";
3-
export { commitChangesFromRepo } from "./git.js";
4-
export { commitFilesFromDirectory } from "./fs.js";
1+
export * as queries from "./github/graphql/queries.ts";
2+
export { commitFilesFromBase64 } from "./core.ts";
3+
export { commitChangesFromRepo } from "./git.ts";
4+
export { commitFilesFromDirectory } from "./fs.ts";

src/interface.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type {
22
CommitMessage,
33
FileChanges,
4-
} from "./github/graphql/generated/types.js";
5-
import type { GitHubClient } from "./github/graphql/queries.js";
6-
import type { Logger } from "./logging.js";
4+
} from "./github/graphql/generated/types.ts";
5+
import type { GitHubClient } from "./github/graphql/queries.ts";
6+
import type { Logger } from "./logging.ts";
77

88
export type CommitFilesResult = {
99
refId: string | null;

src/node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { commitFilesFromBase64 } from "./core.js";
2-
import { CommitFilesFromBuffersArgs, CommitFilesResult } from "./interface.js";
2+
import type {
3+
CommitFilesFromBuffersArgs,
4+
CommitFilesResult,
5+
} from "./interface.ts";
36

47
export const commitFilesFromBuffers = async ({
58
fileChanges,

tests/integration/fs.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { promises as fs } from "fs";
22
import * as path from "path";
33
import { getOctokit } from "@actions/github";
44
import { afterAll, describe, it } from "vitest";
5-
import { commitFilesFromDirectory } from "../../src/fs.js";
5+
import { commitFilesFromDirectory } from "../../src/fs.ts";
66
import {
77
ENV,
88
REPO,
99
ROOT_TEMP_DIRECTORY,
1010
ROOT_TEST_BRANCH_PREFIX,
1111
log,
12-
} from "./env.js";
13-
import { deleteBranches } from "./util.js";
12+
} from "./env.ts";
13+
import { deleteBranches } from "./util.ts";
1414

1515
const octokit = getOctokit(ENV.GITHUB_TOKEN);
1616

0 commit comments

Comments
 (0)