Merge pull request #69 from yordis/chore-tsconfig

chore: improve tsconfigs and deps
This commit is contained in:
Max Peintner
2024-05-17 09:43:02 +02:00
committed by GitHub
34 changed files with 2665 additions and 3359 deletions

View File

@@ -6,7 +6,7 @@
- [ ] Acceptance criteria are met - [ ] Acceptance criteria are met
- [ ] All open todos and follow ups are defined in a new ticket and justified - [ ] All open todos and follow ups are defined in a new ticket and justified
- [ ] Deviations from the acceptance criteria and design are agreed with the PO and documented. - [ ] Deviations from the acceptance criteria and design are agreed with the PO and documented.
- [ ] Jest unit tests ensure that components produce expected outputs on different inputs. - [ ] Vitest unit tests ensure that components produce expected outputs on different inputs.
- [ ] Cypress integration tests ensure that login app pages work as expected. The ZITADEL API is mocked. - [ ] Cypress integration tests ensure that login app pages work as expected. The ZITADEL API is mocked.
- [ ] No debug or dead code - [ ] No debug or dead code
- [ ] My code has no repetitions - [ ] My code has no repetitions

View File

@@ -1,4 +1,7 @@
module.exports = { module.exports = {
extends: ["next/core-web-vitals"], extends: ["next/core-web-vitals"],
ignorePatterns: ["external/**/*.ts"], ignorePatterns: ["external/**/*.ts"],
rules: {
"@next/next/no-html-link-for-pages": "off",
},
}; };

View File

@@ -1,22 +0,0 @@
import type { Config } from "@jest/types";
import { pathsToModuleNameMapper } from "ts-jest";
import { compilerOptions } from "../tsconfig.json";
// We make these type imports explicit, so IDEs with their own typescript engine understand them, too.
import type {} from "@testing-library/jest-dom";
export default async (): Promise<Config.InitialOptions> => {
return {
preset: "ts-jest",
transform: {
"^.+\\.tsx?$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.json" }],
},
setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect"],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: "<rootDir>/../",
}),
testEnvironment: "jsdom",
testRegex: "/__test__/.*\\.test\\.tsx?$",
modulePathIgnorePatterns: ["cypress"],
};
};

View File

@@ -1,7 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"jsx": "react-jsxdev",
"types": ["node", "jest", "@testing-library/jest-dom"]
}
}

View File

@@ -62,4 +62,4 @@ const nextConfig = {
}, },
}; };
module.exports = nextConfig; export default nextConfig;

View File

@@ -5,7 +5,7 @@
"dev": "next dev", "dev": "next dev",
"test": "concurrently --timings --kill-others-on-fail 'npm:test:unit' 'npm:test:integration'", "test": "concurrently --timings --kill-others-on-fail 'npm:test:unit' 'npm:test:integration'",
"test:watch": "concurrently --kill-others 'npm:test:unit:watch' 'npm:test:integration:watch'", "test:watch": "concurrently --kill-others 'npm:test:unit:watch' 'npm:test:integration:watch'",
"test:unit": "jest --config ./__test__/jest.config.ts", "test:unit": "vitest",
"test:unit:watch": "pnpm test:unit --watch", "test:unit:watch": "pnpm test:unit --watch",
"test:integration": "pnpm mock:build && concurrently --names 'mock,test' --success command-test --kill-others 'pnpm:mock' 'env-cmd -f ./.env.integration start-server-and-test start http://localhost:3000 \"test:integration:run\"'", "test:integration": "pnpm mock:build && concurrently --names 'mock,test' --success command-test --kill-others 'pnpm:mock' 'env-cmd -f ./.env.integration start-server-and-test start http://localhost:3000 \"test:integration:run\"'",
"test:integration:watch": "concurrently --names 'mock,test' --kill-others 'pnpm:mock' 'env-cmd -f ./.env.integration start-server-and-test dev http://localhost:3000 \"pnpm nodemon -e js,jsx,ts,tsx,css,scss --ignore \\\"__test__/**\\\" --exec \\\"pnpm test:integration:run\\\"\"'", "test:integration:watch": "concurrently --names 'mock,test' --kill-others 'pnpm:mock' 'env-cmd -f ./.env.integration start-server-and-test dev http://localhost:3000 \"pnpm nodemon -e js,jsx,ts,tsx,css,scss --ignore \\\"__test__/**\\\" --exec \\\"pnpm test:integration:run\\\"\"'",
@@ -42,54 +42,46 @@
"clsx": "1.2.1", "clsx": "1.2.1",
"copy-to-clipboard": "^3.3.3", "copy-to-clipboard": "^3.3.3",
"moment": "^2.29.4", "moment": "^2.29.4",
"next": "13.4.12", "next": "14.2.3",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"nice-grpc": "2.0.1", "nice-grpc": "2.0.1",
"qrcode.react": "^3.1.0", "qrcode.react": "^3.1.0",
"react": "18.2.0", "react": "18.3.1",
"react-dom": "18.2.0", "react-dom": "18.3.1",
"react-hook-form": "7.39.5", "react-hook-form": "7.39.5",
"sass": "^1.62.0",
"swr": "^2.2.0", "swr": "^2.2.0",
"tinycolor2": "1.4.2" "tinycolor2": "1.4.2"
}, },
"devDependencies": { "devDependencies": {
"@zitadel/prettier-config": "workspace:*",
"@bufbuild/buf": "^1.14.0", "@bufbuild/buf": "^1.14.0",
"@jest/types": "^29.5.0", "@testing-library/jest-dom": "^6.4.5",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^15.0.7",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.1",
"@types/ms": "0.7.31", "@types/ms": "0.7.31",
"@types/node": "18.11.9", "@types/node": "18.11.9",
"@types/react": "18.2.8", "@types/react": "18.2.8",
"@types/react-dom": "18.0.9", "@types/react-dom": "18.0.9",
"@types/testing-library__jest-dom": "^5.14.6",
"@types/tinycolor2": "1.4.3", "@types/tinycolor2": "1.4.3",
"@types/uuid": "^9.0.1", "@types/uuid": "^9.0.1",
"@vercel/git-hooks": "1.0.0", "@vercel/git-hooks": "1.0.0",
"@zitadel/prettier-config": "workspace:*",
"@zitadel/tsconfig": "workspace:*", "@zitadel/tsconfig": "workspace:*",
"autoprefixer": "10.4.13", "autoprefixer": "10.4.13",
"concurrently": "^8.1.0", "concurrently": "^8.1.0",
"cypress": "^12.14.0", "cypress": "^13.9.0",
"del-cli": "5.0.0", "del-cli": "5.0.0",
"env-cmd": "^10.1.0", "env-cmd": "^10.1.0",
"eslint-config-zitadel": "workspace:*", "eslint-config-zitadel": "workspace:*",
"grpc-tools": "1.11.3", "grpc-tools": "1.11.3",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-silent-reporter": "^0.5.0",
"lint-staged": "13.0.3", "lint-staged": "13.0.3",
"make-dir-cli": "3.0.0", "make-dir-cli": "3.0.0",
"nodemon": "^2.0.22", "nodemon": "^2.0.22",
"postcss": "8.4.21", "postcss": "8.4.21",
"prettier-plugin-tailwindcss": "0.1.13", "prettier-plugin-tailwindcss": "0.1.13",
"sass": "^1.77.1",
"start-server-and-test": "^2.0.0", "start-server-and-test": "^2.0.0",
"tailwindcss": "3.2.4", "tailwindcss": "3.2.4",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"ts-proto": "^1.139.0", "ts-proto": "^1.139.0",
"typescript": "5.0.4", "typescript": "^5.4.5",
"zitadel-tailwind-config": "workspace:*" "zitadel-tailwind-config": "workspace:*"
} }
} }

View File

@@ -136,7 +136,7 @@ export default async function Page({
<div className="w-full"> <div className="w-full">
{ {
<Alert type={AlertType.ALERT}> <Alert type={AlertType.ALERT}>
{JSON.stringify(error.message)} {JSON.stringify(error.details)}
</Alert> </Alert>
} }
</div> </div>

View File

@@ -1,7 +1,12 @@
import { render, screen, waitFor, within } from "@testing-library/react"; import { expect, describe, test, beforeEach, afterEach } from "vitest";
import PasswordComplexity from "@/ui/PasswordComplexity"; import {
// TODO: Why does this not compile? render,
// import { ResourceOwnerType } from '@zitadel/server'; cleanup,
screen,
waitFor,
within,
} from "@testing-library/react";
import PasswordComplexity from "./PasswordComplexity";
const matchesTitle = `Matches`; const matchesTitle = `Matches`;
const doesntMatchTitle = `Doesn't match`; const doesntMatchTitle = `Doesn't match`;
@@ -33,8 +38,10 @@ describe("<PasswordComplexity/>", () => {
/>, />,
); );
}); });
afterEach(cleanup);
if (expectSVGTitle === false) { if (expectSVGTitle === false) {
it(`should not render the feedback element`, async () => { test(`should not render the feedback element`, async () => {
await waitFor(() => { await waitFor(() => {
expect( expect(
screen.queryByText(feedbackElementLabel), screen.queryByText(feedbackElementLabel),
@@ -42,7 +49,7 @@ describe("<PasswordComplexity/>", () => {
}); });
}); });
} else { } else {
it(`Should show one SVG with title ${expectSVGTitle}`, async () => { test(`Should show one SVG with title ${expectSVGTitle}`, async () => {
await waitFor(async () => { await waitFor(async () => {
const svg = within( const svg = within(
screen.getByText(feedbackElementLabel) screen.getByText(feedbackElementLabel)

View File

@@ -38,11 +38,7 @@ types.forEach((type) => {
module.exports = { module.exports = {
presets: [sharedConfig], presets: [sharedConfig],
darkMode: "class", darkMode: "class",
content: [ content: ["./src/**/*.{js,ts,jsx,tsx}"],
"./app/**/*.{js,ts,jsx,tsx}",
"./page/**/*.{js,ts,jsx,tsx}",
"./ui/**/*.{js,ts,jsx,tsx}",
],
future: { future: {
hoverOnlyWhenSupported: true, hoverOnlyWhenSupported: true,
}, },

View File

@@ -0,0 +1,12 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig({
plugins: [tsconfigPaths(), react()],
test: {
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
environment: "jsdom",
setupFiles: ["@testing-library/jest-dom/vitest"],
},
});

View File

@@ -4,7 +4,7 @@
"generate": "turbo run generate", "generate": "turbo run generate",
"build": "turbo run build", "build": "turbo run build",
"test": "turbo run test", "test": "turbo run test",
"test:unit": "turbo run test:unit", "test:unit": "turbo run test:unit -- --passWithNoTests",
"test:integration": "turbo run test:integration", "test:integration": "turbo run test:integration",
"test:watch": "turbo run test:watch", "test:watch": "turbo run test:watch",
"dev": "turbo run dev --no-cache --continue", "dev": "turbo run dev --no-cache --continue",
@@ -16,12 +16,22 @@
"version-packages": "changeset version", "version-packages": "changeset version",
"release": "turbo run build --filter=login^... && changeset publish" "release": "turbo run build --filter=login^... && changeset publish"
}, },
"pnpm": {
"overrides": {
"@typescript-eslint/parser": "^7.9.0"
}
},
"devDependencies": { "devDependencies": {
"@changesets/cli": "^2.22.0", "@changesets/cli": "^2.22.0",
"eslint": "^7.32.0", "@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-config-zitadel": "workspace:*", "eslint-config-zitadel": "workspace:*",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"turbo": "^1.10.8" "tsup": "^8.0.2",
"turbo": "^1.10.8",
"typescript": "^5.4.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}, },
"packageManager": "pnpm@8.15.5+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589" "packageManager": "pnpm@8.15.5+sha256.4b4efa12490e5055d59b9b9fc9438b7d581a6b7af3b5675eb5c5f447cee1a589"
} }

View File

@@ -4,10 +4,11 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"eslint-config-next": "latest", "eslint-config-next": "^14.2.3",
"eslint-config-prettier": "^8.3.0", "@typescript-eslint/parser": "^7.9.0",
"eslint-plugin-react": "7.28.0", "eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "latest" "eslint-plugin-react": "^7.34.1",
"eslint-config-turbo": "^1.13.3"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@@ -1,8 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node'
}
export default jestConfig

View File

@@ -14,24 +14,17 @@
"build": "tsup --dts", "build": "tsup --dts",
"test": "pnpm test:unit", "test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch", "test:watch": "pnpm test:unit:watch",
"test:unit": "jest", "test:unit": "vitest",
"test:unit:watch": "jest --watch", "test:unit:watch": "vitest --watch",
"dev": "tsup --watch --dts", "dev": "tsup --watch --dts",
"lint": "eslint \"src/**/*.ts*\"", "lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf src/proto" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf src/proto"
}, },
"devDependencies": { "devDependencies": {
"@bufbuild/buf": "^1.14.0", "@bufbuild/buf": "^1.14.0",
"@types/jest": "^29.5.1",
"@zitadel/tsconfig": "workspace:*", "@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*", "eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0", "ts-proto": "^1.139.0"
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"ts-proto": "^1.139.0",
"tsup": "^5.10.1",
"typescript": "^4.9.3"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@@ -1,3 +1,5 @@
import { describe, expect, test, vitest } from "vitest";
import { CallOptions, ClientMiddlewareCall, Metadata, MethodDescriptor } from "nice-grpc-web"; import { CallOptions, ClientMiddlewareCall, Metadata, MethodDescriptor } from "nice-grpc-web";
import { authMiddleware } from "./middleware"; import { authMiddleware } from "./middleware";
@@ -24,9 +26,9 @@ describe('authMiddleware', () => {
]; ];
scenarios.forEach(({ name, initialMetadata, expectedMetadata, token }) => { scenarios.forEach(({ name, initialMetadata, expectedMetadata, token }) => {
it(name, async () => { test(name, async () => {
const mockNext = jest.fn().mockImplementation(async function*() { }); const mockNext = vitest.fn().mockImplementation(async function*() { });
const mockRequest = {}; const mockRequest = {};
const mockMethodDescriptor: MethodDescriptor = { const mockMethodDescriptor: MethodDescriptor = {

View File

@@ -1,8 +1,5 @@
{ {
"extends": "@zitadel/tsconfig/node14.json", "extends": "@zitadel/tsconfig/tsup.json",
"include": ["."], "include": ["./src/**/*"],
"compilerOptions": {
"baseUrl": "."
},
"exclude": ["dist", "build", "node_modules"] "exclude": ["dist", "build", "node_modules"]
} }

View File

@@ -1,8 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node'
}
export default jestConfig

View File

@@ -13,23 +13,16 @@
"build": "tsup", "build": "tsup",
"test": "pnpm test:unit", "test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch", "test:watch": "pnpm test:unit:watch",
"test:unit": "jest --passWithNoTests", "test:unit": "vitest",
"test:unit:watch": "jest --watch", "test:unit:watch": "vitest --watch",
"dev": "tsup --watch", "dev": "tsup --watch",
"lint": "eslint \"src/**/*.ts*\"", "lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.1",
"@types/react": "^17.0.13", "@types/react": "^17.0.13",
"@zitadel/tsconfig": "workspace:*", "@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*", "eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsup": "^5.10.1",
"typescript": "^4.9.3",
"tailwindcss": "3.2.4", "tailwindcss": "3.2.4",
"postcss": "8.4.21", "postcss": "8.4.21",
"zitadel-tailwind-config": "workspace:*", "zitadel-tailwind-config": "workspace:*",
@@ -38,13 +31,13 @@
"peerDependencies": { "peerDependencies": {
"@zitadel/react": "workspace:*", "@zitadel/react": "workspace:*",
"@zitadel/server": "workspace:*", "@zitadel/server": "workspace:*",
"next": "^13", "next": "^14.2.3",
"react": "18.2.0" "react": "18.2.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"dependencies": { "dependencies": {
"next": "^13.4.10" "next": "^14.2.3"
} }
} }

View File

@@ -1,9 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: [ '@testing-library/jest-dom/extend-expect' ]
}
export default jestConfig

View File

@@ -7,41 +7,36 @@
], ],
"license": "MIT", "license": "MIT",
"exports": { "exports": {
".": "./dist", ".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./styles.css": "./dist/index.css", "./styles.css": "./dist/index.css",
"./assets/*": "./dist/assets/*" "./assets/*": "./dist/assets/*"
}, },
"scripts": { "scripts": {
"build": "tsup src/index.tsx --format esm,cjs --dts --external react", "build": "tsup",
"test": "pnpm test:unit", "test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch", "test:watch": "pnpm test:unit:watch",
"test:unit": "jest", "test:unit": "vitest",
"test:unit:watch": "jest --watch", "test:unit:watch": "vitest --watch",
"dev": "tsup --watch", "dev": "tsup --watch",
"lint": "eslint \"src/**/*.ts*\"", "lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"copy-files": "cp -R ./src/public/ ./dist/" "copy-files": "cp -R ./src/public/ ./dist/"
}, },
"devDependencies": { "devDependencies": {
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^14.0.0", "@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.1",
"@types/react": "^18.2.17", "@types/react": "^18.2.17",
"@types/react-dom": "^18.2.7", "@types/react-dom": "^18.2.7",
"@types/testing-library__jest-dom": "^5.14.6",
"@zitadel/tsconfig": "workspace:*", "@zitadel/tsconfig": "workspace:*",
"autoprefixer": "10.4.13", "autoprefixer": "10.4.13",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*", "eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0", "jsdom": "^24.0.0",
"jest-environment-jsdom": "^29.5.0",
"postcss": "8.4.21", "postcss": "8.4.21",
"sass": "^1.62.0", "sass": "^1.77.1",
"tailwindcss": "3.2.4", "tailwindcss": "3.2.4",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6",
"zitadel-tailwind-config": "workspace:*" "zitadel-tailwind-config": "workspace:*"
}, },
"publishConfig": { "publishConfig": {

View File

@@ -1,19 +1,23 @@
import { render, screen } from "@testing-library/react"; import { afterEach, describe, expect, test } from "vitest";
import { cleanup, render, screen } from "@testing-library/react";
import { SignInWithGitlab } from "./SignInWithGitlab"; import { SignInWithGitlab } from "./SignInWithGitlab";
afterEach(cleanup);
describe("<SignInWithGitlab />", () => { describe("<SignInWithGitlab />", () => {
it("renders without crashing", () => { test("renders without crashing", () => {
const { container } = render(<SignInWithGitlab />); const { container } = render(<SignInWithGitlab />);
expect(container.firstChild).toBeDefined(); expect(container.firstChild).toBeDefined();
}); });
it("displays the default text", () => { test("displays the default text", () => {
render(<SignInWithGitlab />); render(<SignInWithGitlab />);
const signInText = screen.getByText(/Sign in with Gitlab/i); const signInText = screen.getByText(/Sign in with Gitlab/i);
expect(signInText).toBeInTheDocument(); expect(signInText).toBeInTheDocument();
}); });
it("displays the given text", () => { test("displays the given text", () => {
render(<SignInWithGitlab name={"Gitlab"} />); render(<SignInWithGitlab name={"Gitlab"} />);
const signInText = screen.getByText(/Gitlab/i); const signInText = screen.getByText(/Gitlab/i);
expect(signInText).toBeInTheDocument(); expect(signInText).toBeInTheDocument();

View File

@@ -1,19 +1,23 @@
import { render, screen } from "@testing-library/react"; import { afterEach, describe, expect, test } from "vitest";
import { cleanup, render, screen } from "@testing-library/react";
import { SignInWithGoogle } from "./SignInWithGoogle"; import { SignInWithGoogle } from "./SignInWithGoogle";
afterEach(cleanup);
describe("<SignInWithGoogle />", () => { describe("<SignInWithGoogle />", () => {
it("renders without crashing", () => { test("renders without crashing", () => {
const { container } = render(<SignInWithGoogle />); const { container } = render(<SignInWithGoogle />);
expect(container.firstChild).toBeDefined(); expect(container.firstChild).toBeDefined();
}); });
it("displays the default text", () => { test("displays the default text", () => {
render(<SignInWithGoogle />); render(<SignInWithGoogle />);
const signInText = screen.getByText(/Sign in with Google/i); const signInText = screen.getByText(/Sign in with Google/i);
expect(signInText).toBeInTheDocument(); expect(signInText).toBeInTheDocument();
}); });
it("displays the given text", () => { test("displays the given text", () => {
render(<SignInWithGoogle name={"Google"} />); render(<SignInWithGoogle name={"Google"} />);
const signInText = screen.getByText(/Google/i); const signInText = screen.getByText(/Google/i);
expect(signInText).toBeInTheDocument(); expect(signInText).toBeInTheDocument();

View File

@@ -0,0 +1,9 @@
import { defineConfig, Options } from "tsup";
export default defineConfig((options: Options) => ({
entry: ["src/index.tsx"],
format: ["esm", "cjs"],
dts: true,
external: ["react"],
...options,
}));

View File

@@ -0,0 +1,11 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
test: {
include: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
environment: "jsdom",
setupFiles: ["@testing-library/jest-dom/vitest"],
},
});

View File

@@ -1,8 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node'
}
export default jestConfig

View File

@@ -15,24 +15,17 @@
"build": "tsup --dts", "build": "tsup --dts",
"test": "pnpm test:unit", "test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch", "test:watch": "pnpm test:unit:watch",
"test:unit": "jest", "test:unit": "vitest",
"test:unit:watch": "jest --watch", "test:unit:watch": "vitest --watch",
"dev": "tsup --dts --watch", "dev": "tsup --dts --watch",
"lint": "eslint \"src/**/*.ts*\"", "lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf src/proto" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf src/proto"
}, },
"devDependencies": { "devDependencies": {
"@bufbuild/buf": "^1.14.0", "@bufbuild/buf": "^1.14.0",
"@types/jest": "^29.5.1",
"@zitadel/tsconfig": "workspace:*", "@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*", "eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0", "ts-proto": "^1.139.0"
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"ts-proto": "^1.139.0",
"tsup": "^5.10.1",
"typescript": "^4.9.3"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
@@ -44,4 +37,4 @@
"nice-grpc-common": "^2.0.2", "nice-grpc-common": "^2.0.2",
"protobufjs": "^7.2.3" "protobufjs": "^7.2.3"
} }
} }

View File

@@ -1,3 +1,5 @@
import { describe, expect, test, vitest } from "vitest";
import { CallOptions, ClientMiddlewareCall, Metadata, MethodDescriptor } from "nice-grpc"; import { CallOptions, ClientMiddlewareCall, Metadata, MethodDescriptor } from "nice-grpc";
import { authMiddleware } from "./middleware"; import { authMiddleware } from "./middleware";
@@ -24,9 +26,9 @@ describe('authMiddleware', () => {
]; ];
scenarios.forEach(({ name, initialMetadata, expectedMetadata, token }) => { scenarios.forEach(({ name, initialMetadata, expectedMetadata, token }) => {
it(name, async () => { test(name, async () => {
const mockNext = jest.fn().mockImplementation(async function*() { }); const mockNext = vitest.fn().mockImplementation(async function*() { });
const mockRequest = {}; const mockRequest = {};
const mockMethodDescriptor: MethodDescriptor = { const mockMethodDescriptor: MethodDescriptor = {

View File

@@ -1,9 +1,5 @@
{ {
"extends": "@zitadel/tsconfig/node14.json", "extends": "@zitadel/tsconfig/tsup.json",
"include": ["src/**/*.ts"], "include": ["./src/**/*"],
"compilerOptions": {
"baseUrl": ".",
"rootDir": "src"
},
"exclude": ["dist", "build", "node_modules"] "exclude": ["dist", "build", "node_modules"]
} }

View File

@@ -9,7 +9,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"inlineSources": false, "inlineSources": false,
"isolatedModules": true, "isolatedModules": true,
"moduleResolution": "node", "moduleResolution": "node16",
"noUnusedLocals": false, "noUnusedLocals": false,
"noUnusedParameters": false, "noUnusedParameters": false,
"preserveWatchOutput": true, "preserveWatchOutput": true,

View File

@@ -12,11 +12,14 @@
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"incremental": true, "incremental": true,
"preserveSymlinks": true,
"declaration": false,
"declarationMap": false,
"baseUrl": ".", "baseUrl": ".",
"plugins": [ "plugins": [
{ {

View File

@@ -1,10 +1,10 @@
{ {
"$schema": "https://json.schemastore.org/tsconfig", "$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 14", "display": "Node 20",
"extends": "./base.json", "extends": "./base.json",
"compilerOptions": { "compilerOptions": {
"lib": ["ES2020"], "lib": ["es2023"],
"module": "commonjs", "module": "node16",
"target": "ES2020" "target": "es2022"
} }
} }

View File

@@ -5,7 +5,7 @@
"compilerOptions": { "compilerOptions": {
"jsx": "react-jsx", "jsx": "react-jsx",
"lib": ["dom", "ES2015"], "lib": ["dom", "ES2015"],
"module": "ESNext", "module": "preserve",
"target": "es6" "moduleResolution": "Bundler"
} }
} }

View File

@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "tsup",
"extends": "./node20.json",
"compilerOptions": {
"module": "preserve",
"moduleResolution": "Bundler"
}
}

5696
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff