diff --git a/.dependency-cruiser.cjs b/.dependency-cruiser.cjs index cb7df1bd..0e682527 100644 --- a/.dependency-cruiser.cjs +++ b/.dependency-cruiser.cjs @@ -57,7 +57,7 @@ module.exports = { "from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration", from: { path: "^(src|app|lib)", - pathNot: "\\.spec\\.(js|ts|ls|coffee|litcoffee|coffee\\.md)$", + pathNot: "(\\.spec\\.(js|ts|ls|coffee|litcoffee|coffee\\.md)$|__tests__|[-.]test\\.ts$)", }, to: { dependencyTypes: ["npm-dev"], diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5dce897d..62126501 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: - name: Test & Build run: | pnpm build + pnpm type-check pnpm test:code:gen pnpm test env: diff --git a/lefthook.yml b/lefthook.yml index c2eb40b9..01a8b6df 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -2,7 +2,7 @@ pre-commit: commands: format: glob: "*.{js,jsx,json,yml,yaml,html,md,ts,tsx}" - run: biome format --no-errors-on-unmatched --write {staged_files} + run: pnpm exec biome format --no-errors-on-unmatched --write {staged_files} stage_fixed: true sort-package-json: glob: "package.json" diff --git a/package.json b/package.json index aacdd1bc..08dbc6c7 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "test:snapshot": "vitest run --config ./vitest.snapshot.config.ts", "test:vitest": "vitest run --config ./vitest.config.ts --coverage", "ts": "node --no-warnings=ExperimentalWarning --experimental-specifier-resolution=node --loader ts-node/esm", + "type-check": "tsc --noEmit", "update:snapshot": "vitest run --config ./vitest.snapshot.config.ts --update", "validate": "pnpm ts ./scripts/validate.ts", "watch": "pnpm ts ./scripts/watch.ts" diff --git a/scripts/tools/shell.ts b/scripts/tools/shell.ts index ffd91c82..27d12655 100644 --- a/scripts/tools/shell.ts +++ b/scripts/tools/shell.ts @@ -1,6 +1,6 @@ -import { ExecaChildProcess, execa } from "execa"; +import { type ResultPromise, execa } from "execa"; -export const shell = (command: string, cwd: string = process.cwd()): ExecaChildProcess => { +export const shell = (command: string, cwd: string = process.cwd()): ResultPromise => { return execa(command, { stdio: ["pipe", "pipe", "inherit"], shell: true, diff --git a/src/code-templates/_shared/MethodBody/__tests__/PathParameter-test.ts b/src/code-templates/_shared/MethodBody/__tests__/PathParameter-test.ts index 0383d489..ef430e5c 100644 --- a/src/code-templates/_shared/MethodBody/__tests__/PathParameter-test.ts +++ b/src/code-templates/_shared/MethodBody/__tests__/PathParameter-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import ts from "typescript"; import { TsGenerator } from "../../../../api"; diff --git a/src/code-templates/_shared/__tests__/utils.test.ts b/src/code-templates/_shared/__tests__/utils.test.ts index 082afe3a..f811cf7f 100644 --- a/src/code-templates/_shared/__tests__/utils.test.ts +++ b/src/code-templates/_shared/__tests__/utils.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as Utils from "../utils"; type OK = Utils.VariableElement; diff --git a/src/internal/OpenApiTools/Walker/Store.ts b/src/internal/OpenApiTools/Walker/Store.ts index b9596e53..c0028283 100644 --- a/src/internal/OpenApiTools/Walker/Store.ts +++ b/src/internal/OpenApiTools/Walker/Store.ts @@ -153,7 +153,7 @@ class Store { if (!result) { throw new Error(`Not found ${localPath}`); } - return result; + return result as OpenApi.Parameter; } public isAfterDefined(referencePath: string): boolean { return !!DotProp.getProperty(this.state.document, referencePath.replace(/\//g, ".")); diff --git a/test/__tests__/class/argo-rollout-test.ts b/test/__tests__/class/argo-rollout-test.ts index ae42001f..a1dbe6a3 100644 --- a/test/__tests__/class/argo-rollout-test.ts +++ b/test/__tests__/class/argo-rollout-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/cloudflare-test.ts b/test/__tests__/class/cloudflare-test.ts index c21db5f1..12049bf4 100644 --- a/test/__tests__/class/cloudflare-test.ts +++ b/test/__tests__/class/cloudflare-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/format.domain.ts b/test/__tests__/class/format.domain.ts index cdf234cf..06ea67b1 100644 --- a/test/__tests__/class/format.domain.ts +++ b/test/__tests__/class/format.domain.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/kubernetes-test.ts b/test/__tests__/class/kubernetes-test.ts index 7ccd2690..87eb742e 100644 --- a/test/__tests__/class/kubernetes-test.ts +++ b/test/__tests__/class/kubernetes-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/multi-type.test.domain.ts b/test/__tests__/class/multi-type.test.domain.ts index 9155f4fb..4685f314 100644 --- a/test/__tests__/class/multi-type.test.domain.ts +++ b/test/__tests__/class/multi-type.test.domain.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/parameter-test.ts b/test/__tests__/class/parameter-test.ts index c87e942e..25b88fa6 100644 --- a/test/__tests__/class/parameter-test.ts +++ b/test/__tests__/class/parameter-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/spit-code-test.ts b/test/__tests__/class/spit-code-test.ts index 6218286e..c70dbbc9 100644 --- a/test/__tests__/class/spit-code-test.ts +++ b/test/__tests__/class/spit-code-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/template-only-test.ts b/test/__tests__/class/template-only-test.ts index 35959325..6078953f 100644 --- a/test/__tests__/class/template-only-test.ts +++ b/test/__tests__/class/template-only-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/typedef-only-test.ts b/test/__tests__/class/typedef-only-test.ts index ba69e229..0aab2bef 100644 --- a/test/__tests__/class/typedef-only-test.ts +++ b/test/__tests__/class/typedef-only-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/typedef-with-template-test.ts b/test/__tests__/class/typedef-with-template-test.ts index c5d16c94..fff17508 100644 --- a/test/__tests__/class/typedef-with-template-test.ts +++ b/test/__tests__/class/typedef-with-template-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/class/unknown-schema-domain-test.ts b/test/__tests__/class/unknown-schema-domain-test.ts index add08db7..ae7a84b7 100644 --- a/test/__tests__/class/unknown-schema-domain-test.ts +++ b/test/__tests__/class/unknown-schema-domain-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/client-generate-test.ts b/test/__tests__/client-generate-test.ts index f31d3276..44fb780b 100644 --- a/test/__tests__/client-generate-test.ts +++ b/test/__tests__/client-generate-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import { CodeGenerator } from "../../src"; diff --git a/test/__tests__/currying-functional/coudflare-test.ts b/test/__tests__/currying-functional/coudflare-test.ts index 3405fe7f..3fa79fcb 100644 --- a/test/__tests__/currying-functional/coudflare-test.ts +++ b/test/__tests__/currying-functional/coudflare-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/argo-rollout-test.ts b/test/__tests__/functional/argo-rollout-test.ts index 3b24c6e3..064bca64 100644 --- a/test/__tests__/functional/argo-rollout-test.ts +++ b/test/__tests__/functional/argo-rollout-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/coudflare-test.ts b/test/__tests__/functional/coudflare-test.ts index 2578a301..29aa165a 100644 --- a/test/__tests__/functional/coudflare-test.ts +++ b/test/__tests__/functional/coudflare-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/format.domain.ts b/test/__tests__/functional/format.domain.ts index 17696593..a4f45063 100644 --- a/test/__tests__/functional/format.domain.ts +++ b/test/__tests__/functional/format.domain.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/kubernetes-test.ts b/test/__tests__/functional/kubernetes-test.ts index d4151acc..d9c2915b 100644 --- a/test/__tests__/functional/kubernetes-test.ts +++ b/test/__tests__/functional/kubernetes-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/multi-type.test.domain.ts b/test/__tests__/functional/multi-type.test.domain.ts index 74a1dd6d..bb93fe8c 100644 --- a/test/__tests__/functional/multi-type.test.domain.ts +++ b/test/__tests__/functional/multi-type.test.domain.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/parameter-test.ts b/test/__tests__/functional/parameter-test.ts index 603fbc03..912cb393 100644 --- a/test/__tests__/functional/parameter-test.ts +++ b/test/__tests__/functional/parameter-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/spit-code-test.ts b/test/__tests__/functional/spit-code-test.ts index 7cd3eaaa..d7ffb3e2 100644 --- a/test/__tests__/functional/spit-code-test.ts +++ b/test/__tests__/functional/spit-code-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/template-only-test.ts b/test/__tests__/functional/template-only-test.ts index ebc32955..c97c04e6 100644 --- a/test/__tests__/functional/template-only-test.ts +++ b/test/__tests__/functional/template-only-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/typedef-only-test.ts b/test/__tests__/functional/typedef-only-test.ts index 13a02b8b..ec43ef53 100644 --- a/test/__tests__/functional/typedef-only-test.ts +++ b/test/__tests__/functional/typedef-only-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/typedef-with-template-test.ts b/test/__tests__/functional/typedef-with-template-test.ts index ac6421e8..9bb15858 100644 --- a/test/__tests__/functional/typedef-with-template-test.ts +++ b/test/__tests__/functional/typedef-with-template-test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it, test } from "vitest"; import * as fs from "fs"; import * as Utils from "../../utils"; diff --git a/test/__tests__/functional/unknown-schema-domain-test copy.ts b/test/__tests__/functional/unknown-schema-domain-test copy.ts deleted file mode 100644 index 39984a4f..00000000 --- a/test/__tests__/functional/unknown-schema-domain-test copy.ts +++ /dev/null @@ -1,11 +0,0 @@ -import * as fs from "fs"; - -import * as Utils from "../../utils"; - -describe("Unknown", () => { - test("client.ts", () => { - const generateCode = fs.readFileSync("test/code/functional/unknown.schema.domain/client.ts", { encoding: "utf-8" }); - const text = Utils.replaceVersionInfo(generateCode); - expect(text).toMatchSnapshot(); - }); -}); diff --git a/tsconfig.json b/tsconfig.json index bfb3a9b8..46971edc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,5 +19,6 @@ "ts-node": { "esm": true, "swc": true - } + }, + "exclude": ["test/code", "examples/"] }