diff --git a/.eslintignore b/.eslintignore index 91f29fbc7..176d4a6bc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ node_modules pnpm-lock.yaml packages/*/docs packages/*/coverage +*tsconfig.tsbuildinfo* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24a9198ce..c74406fc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} NX_CLOUD_DISTRIBUTED_EXECUTION: true CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CI: true # recommended to set a concurrency group concurrency: @@ -15,6 +16,7 @@ concurrency: jobs: pr: runs-on: ubuntu-latest + timeout-minutes: 10 permissions: pull-requests: write contents: write @@ -44,7 +46,7 @@ jobs: - run: git branch --track main origin/main - run: pnpm exec nx-cloud record -- nx format:check - - run: pnpm exec nx affected -t typecheck build lint test docs e2e-ci + - run: pnpm exec nx affected -t build typecheck lint test docs e2e-ci - uses: codecov/codecov-action@v5 with: diff --git a/e2e/davinci-app/package.json b/e2e/davinci-app/package.json index e42344e81..1edd91c1c 100644 --- a/e2e/davinci-app/package.json +++ b/e2e/davinci-app/package.json @@ -13,9 +13,6 @@ }, "devDependencies": {}, "scripts": { - "build": "nx exec -- vite build --watch false", - "serve": "vite dev", - "preview": "vite preview", - "lint": "nx exec -- eslint **/*.ts --fix" + "lint": "eslint **/*.ts --fix" } } diff --git a/e2e/davinci-app/tsconfig.json b/e2e/davinci-app/tsconfig.json index 14186f2dd..9db433b0c 100644 --- a/e2e/davinci-app/tsconfig.json +++ b/e2e/davinci-app/tsconfig.json @@ -6,9 +6,6 @@ "useDefineForClassFields": true, "lib": ["ESNext", "DOM"], "strict": true, - "resolveJsonModule": true, - "moduleDetection": "force", - "verbatimModuleSyntax": true, "isolatedModules": true, "esModuleInterop": true, "noUnusedLocals": true, diff --git a/e2e/mock-api-v2/.eslintignore b/e2e/mock-api-v2/.eslintignore index 0360812cd..094b3eca0 100644 --- a/e2e/mock-api-v2/.eslintignore +++ b/e2e/mock-api-v2/.eslintignore @@ -8,3 +8,4 @@ dist .eslintignore coverage html/* +*tsconfig.tsbuildinfo* diff --git a/e2e/mock-api-v2/build.js b/e2e/mock-api-v2/build.js deleted file mode 100644 index 2f9204e9d..000000000 --- a/e2e/mock-api-v2/build.js +++ /dev/null @@ -1,35 +0,0 @@ -// build.js -const esbuild = require('esbuild'); -const process = require('process'); -const fs = require('fs'); -const path = require('path'); - -const { env } = process; - -const production = Boolean(env?.PROD) ?? false; -const watch = Boolean(env?.WATCH) ?? false; - -esbuild - .build({ - entryPoints: ['src/main.ts'], - bundle: true, - platform: 'node', - target: 'node20', // or your preferred Node.js version - assetNames: 'assets', - format: 'esm', - outfile: 'dist/main.js', - sourcemap: true, - watch, - minify: production, // Set to true for production - }) - .then(() => { - // Copy CSS file to dist directory - fs.copyFileSync( - path.join(__dirname, 'src', 'index.css'), - path.join(__dirname, 'dist', 'index.css'), - ); - console.log('CSS file copied to dist directory'); - - console.log('Build completed successfully!'); - }) - .catch(() => process.exit(1)); diff --git a/e2e/mock-api-v2/package.json b/e2e/mock-api-v2/package.json index f531fd8a1..7c0914262 100644 --- a/e2e/mock-api-v2/package.json +++ b/e2e/mock-api-v2/package.json @@ -3,16 +3,7 @@ "version": "1.0.0", "description": "", "main": "./dist/index.js", - "type": "commonjs", - "scripts": { - "build": "tsc --project tsconfig.app.json", - "build:watch": "tsc --project tsconfig.app.json --watch", - "serve": "node dist/e2e/mock-api-v2/src/main.js", - "serve:dev": "nodemon dist/e2e/mock-api-v2/src/main.js", - "test": "vitest", - "test:watch": "vitest watch --coverage --coverage.reportsDirectory=../../coverage/mock-api-v2", - "lint": "nx exec -- eslint --fix --ignore-path .eslintignore \"**/*.ts\"" - }, + "type": "module", "dependencies": { "@effect/language-service": "^0.2.0", "@effect/platform": "^0.58.27", @@ -20,7 +11,26 @@ "effect": "^3.12.7", "effect-http": "^0.73.0", "effect-http-node": "^0.16.1", - "@effect/schema": "^0.68.23", + "@effect/schema": "^0.68.23" + }, + "devDependencies": { + "vitest": "^3.0.4", "@effect/vitest": "^0.17.3" + }, + "nx": { + "tags": ["scope:e2e"], + "targets": { + "build": { + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "e2e/mock-api-v2/dist", + "main": "e2e/mock-api-v2/src/main.ts", + "tsConfig": "e2e/mock-api-v2/tsconfig.app.json", + "generatePackageJson": true, + "assets": [] + } + } + } } } diff --git a/e2e/mock-api-v2/src/helpers/test/cookie.test.ts b/e2e/mock-api-v2/src/helpers/test/cookie.test.ts index d89a5090a..16b4fed6d 100644 --- a/e2e/mock-api-v2/src/helpers/test/cookie.test.ts +++ b/e2e/mock-api-v2/src/helpers/test/cookie.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { expect } from 'vitest'; import { getElementFromCookie, incrementCookieHeader, diff --git a/e2e/mock-api-v2/src/helpers/test/match.test.ts b/e2e/mock-api-v2/src/helpers/test/match.test.ts index 10ee30d6b..37cbe0b38 100644 --- a/e2e/mock-api-v2/src/helpers/test/match.test.ts +++ b/e2e/mock-api-v2/src/helpers/test/match.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { expect } from 'vitest'; import { PingRequestData, validator } from '../match.js'; import { Effect, Exit } from 'effect'; import { InvalidUsernamePassword, InvalidProtectNode } from '../../errors/index.js'; diff --git a/e2e/mock-api-v2/src/services/tests/authorize.service.test.ts b/e2e/mock-api-v2/src/services/tests/authorize.service.test.ts index a3cd13663..866e729b3 100644 --- a/e2e/mock-api-v2/src/services/tests/authorize.service.test.ts +++ b/e2e/mock-api-v2/src/services/tests/authorize.service.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { expect } from 'vitest'; import { Effect, Layer } from 'effect'; import { Authorize, authorizeMock } from '../authorize.service.js'; import { mockRequest } from '../request.service.js'; diff --git a/e2e/mock-api-v2/src/services/tests/cookie.service.test.ts b/e2e/mock-api-v2/src/services/tests/cookie.service.test.ts index a792f15e6..14a2e4edf 100644 --- a/e2e/mock-api-v2/src/services/tests/cookie.service.test.ts +++ b/e2e/mock-api-v2/src/services/tests/cookie.service.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { vi, afterEach, beforeEach, expect } from 'vitest'; import { CookieService, cookieServiceTest } from '../cookie.service.js'; import { Effect, Either } from 'effect'; import { Cookies } from '@effect/platform'; diff --git a/e2e/mock-api-v2/src/services/tests/custom-html-template.service.test.ts b/e2e/mock-api-v2/src/services/tests/custom-html-template.service.test.ts index 7083747e6..596b1db3d 100644 --- a/e2e/mock-api-v2/src/services/tests/custom-html-template.service.test.ts +++ b/e2e/mock-api-v2/src/services/tests/custom-html-template.service.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { expect } from 'vitest'; import { CustomHtmlTemplate, mockCustomHtmlTemplate } from '../custom-html-template.service.js'; import { Effect, Exit, Layer } from 'effect'; import { mockRequest } from '../request.service.js'; diff --git a/e2e/mock-api-v2/src/services/tests/request.service.test.ts b/e2e/mock-api-v2/src/services/tests/request.service.test.ts index 8a45001ea..57f8e98ea 100644 --- a/e2e/mock-api-v2/src/services/tests/request.service.test.ts +++ b/e2e/mock-api-v2/src/services/tests/request.service.test.ts @@ -1,4 +1,5 @@ -import { it, expect } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { expect } from 'vitest'; import { Request, mockRequest } from '../request.service.js'; import { Effect } from 'effect'; import { CustomHtmlResponseBody } from '../custom-html-template.service.js'; diff --git a/e2e/mock-api-v2/src/services/tests/userinfo.service.test.ts b/e2e/mock-api-v2/src/services/tests/userinfo.service.test.ts index 6b57b6875..da0dd98fb 100644 --- a/e2e/mock-api-v2/src/services/tests/userinfo.service.test.ts +++ b/e2e/mock-api-v2/src/services/tests/userinfo.service.test.ts @@ -1,4 +1,5 @@ -import { expect, it } from '@effect/vitest'; +import { it } from '@effect/vitest'; +import { expect } from 'vitest'; import { UserInfo, userInfoMock } from '../userinfo.service.js'; import { userInfoResponse } from '../../responses/userinfo/userinfo.js'; import { Effect } from 'effect'; diff --git a/e2e/mock-api-v2/tsconfig.spec.json b/e2e/mock-api-v2/tsconfig.spec.json index 72ea49cbd..924c896d5 100644 --- a/e2e/mock-api-v2/tsconfig.spec.json +++ b/e2e/mock-api-v2/tsconfig.spec.json @@ -2,20 +2,13 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "NodeNext", - "moduleResolution": "NodeNext", - "target": "ES2020", - "types": [ - "vitest/vitest", - "vitest/globals", - "vitest/importMeta", - "vite/client", - "node" - ] + "module": "Node16", + "moduleResolution": "Node16", + "types": ["vitest/importMeta", "vite/client", "node"] }, "include": [ "src/**/*.ts", - "vite.config.ts", + "vite.config.mts", "vitest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", diff --git a/e2e/mock-api-v2/vite.config.ts b/e2e/mock-api-v2/vite.config.ts index f85e2d61a..54e3a0e02 100644 --- a/e2e/mock-api-v2/vite.config.ts +++ b/e2e/mock-api-v2/vite.config.ts @@ -5,14 +5,10 @@ export default defineConfig({ cacheDir: '../../node_modules/.vite/e2e/mock-api-v2', test: { - globals: true, - cache: { - dir: '../../node_modules/.vitest', - }, - watch: !process.env['CI'], + globals: false, + watch: Boolean(process.env['CI']) === false, environment: 'jsdom', include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - reporters: ['default', 'json', 'html'], coverage: { enabled: Boolean(process.env['CI']), diff --git a/nx.json b/nx.json index e1fe46526..df09cd69b 100644 --- a/nx.json +++ b/nx.json @@ -13,7 +13,8 @@ }, "targetDefaults": { "typecheck": { - "dependsOn": ["build", "^build"] + "outputs": ["{projectRoot}/out-tsc"], + "dependsOn": ["^typecheck"] }, "docs": { "dependsOn": ["build", "^build", "^docs"], @@ -26,7 +27,7 @@ "e2e": { "dependsOn": ["^e2e"], "inputs": ["noMarkdown", "^noMarkdown"], - "outputs": ["{projectRoot}/./.playwright"], + "outputs": ["{projectRoot}/.playwright"], "cache": true }, "lint": { @@ -37,13 +38,13 @@ "test": { "inputs": ["noMarkdown", "^noMarkdown"], "dependsOn": ["^test"], - "outputs": ["{projectRoot}/./coverage"], + "outputs": ["{projectRoot}/coverage"], "cache": true }, "build": { "inputs": ["noMarkdown", "^noMarkdown"], "dependsOn": ["^build"], - "outputs": ["{projectRoot}/./dist"], + "outputs": ["{projectRoot}/dist"], "cache": true }, "e2e-ci--**/*": { @@ -80,6 +81,9 @@ "cache": true } }, + "sync": { + "applyChanges": true + }, "plugins": [ { "plugin": "@nx/js/typescript", @@ -91,21 +95,23 @@ "targetName": "build", "configName": "tsconfig.lib.json" } - } + }, + "include": ["e2e/**/**/*", "packages/**/**/*"] }, { "plugin": "@nx/playwright/plugin", "options": { "ciTargetName": "e2e-ci", "targetName": "e2e" - } + }, + "include": ["e2e/**/**/*"] }, { "plugin": "@nx/eslint/plugin", "options": { "targetName": "lint" }, - "include": ["tools/create-package/**/*", "packages/**/**/*"] + "include": ["e2e/**/**/*", "packages/**/**/*"] }, { "plugin": "@nx/vite/plugin", @@ -117,7 +123,7 @@ "serveStaticTargetName": "serve-static", "typecheckTargetName": "typecheck" }, - "include": ["tools/create-package/**/*"] + "include": ["packages/**/**/*", "e2e/**/**/*"] } ], "parallel": 1, @@ -125,9 +131,6 @@ "appsDir": "", "libsDir": "" }, - "sync": { - "applyChanges": true - }, "generators": { "@nx/js:library": { "publishable": true, diff --git a/package.json b/package.json index 1305b2bb5..9ebae9c49 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "@typescript-eslint/parser": "7.16.1", "@typescript-eslint/typescript-estree": "5.59.5", "@typescript-eslint/utils": "^8.13.0", - "@vitest/coverage-v8": "^3.0.4", - "@vitest/ui": "^3.0.4", + "@vitest/coverage-v8": "3.0.4", + "@vitest/ui": "3.0.4", "conventional-changelog-conventionalcommits": "^7.0.2", "cz-conventional-changelog": "^3.3.0", "cz-git": "^1.6.1", @@ -95,7 +95,7 @@ "vite-plugin-eslint": "^1.8.1", "vite-plugin-externalize-deps": "^0.8.0", "vite-tsconfig-paths": "^4.3.2", - "vitest": "^3.0.4", + "vitest": "3.0.4", "vitest-canvas-mock": "^0.3.3" }, "config": { diff --git a/packages/davinci-client/.eslintignore b/packages/davinci-client/.eslintignore index 288d66ab2..309688b91 100644 --- a/packages/davinci-client/.eslintignore +++ b/packages/davinci-client/.eslintignore @@ -9,3 +9,4 @@ dist docs coverage vite.config.*.timestamp* +*tsconfig.tsbuildinfo* diff --git a/packages/davinci-client/.eslintrc.json b/packages/davinci-client/.eslintrc.json index 5a28bc406..df1d6d4dc 100644 --- a/packages/davinci-client/.eslintrc.json +++ b/packages/davinci-client/.eslintrc.json @@ -19,7 +19,7 @@ "parser": "jsonc-eslint-parser", "rules": { "@nx/dependency-checks": [ - "error", + "warn", { "ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"] } diff --git a/packages/davinci-client/package.json b/packages/davinci-client/package.json index 0be9ab197..80672337f 100644 --- a/packages/davinci-client/package.json +++ b/packages/davinci-client/package.json @@ -20,17 +20,13 @@ "@reduxjs/toolkit": "catalog:", "immer": "catalog:" }, + "devDependencies": { + "vitest": "3.0.4" + }, "exports": { ".": "./dist/src/index.js", "./types": "./dist/src/types.d.ts" }, - "scripts": { - "build": "nx exec -- tsc --project ./tsconfig.lib.json", - "test": "nx exec -- vitest --typecheck", - "test:watch": "vitest --watch", - "test:coverage": "nx exec -- vitest --coverage", - "lint": "nx exec -- eslint **/*.ts --fix" - }, "nx": { "tags": ["scope:package"], "targets": { diff --git a/packages/davinci-client/src/lib/collector.utils.test.ts b/packages/davinci-client/src/lib/collector.utils.test.ts index b0bc62220..7b9555f48 100644 --- a/packages/davinci-client/src/lib/collector.utils.test.ts +++ b/packages/davinci-client/src/lib/collector.utils.test.ts @@ -83,7 +83,9 @@ describe('Action Collectors', () => { // this type could be more comprehensive // that is why casting as any here works const result = returnSocialLoginCollector(fieldWithoutUrl, 1); - expect(result.output.url).toBeNull(); + if ('url' in result.output) { + expect(result.output.url).toBeNull(); + } }); it('should handle error cases properly', () => { @@ -210,13 +212,15 @@ describe('Action Collectors', () => { it('handles missing authentication URL for social login', () => { const result = returnActionCollector(mockField, 1, 'SocialLoginCollector'); - expect(result.output.url).toBeNull(); + if ('url' in result.output) { + expect(result.output.url).toBeNull(); + } }); it('should return an error message when field is missing key, label, or type', () => { const field = {}; const idx = 3; - const result = returnActionCollector(field, idx, 'ActionCollector'); + const result = returnActionCollector(field as StandardFieldValue, idx, 'ActionCollector'); expect(result.error).toBe( 'Key is not found in the field object. Label is not found in the field object. Type is not found in the field object. ', ); @@ -279,7 +283,11 @@ describe('Single Value Collectors', () => { it('should return an error message when field is missing key, label, or type', () => { const field = {}; const idx = 3; - const result = returnSingleValueCollector(field, idx, 'SingleValueCollector'); + const result = returnSingleValueCollector( + field as StandardFieldValue, + idx, + 'SingleValueCollector', + ); expect(result.error).toBe( 'Key is not found in the field object. Label is not found in the field object. Type is not found in the field object. ', ); diff --git a/packages/davinci-client/src/lib/mock-data/mock-form-fields.data.ts b/packages/davinci-client/src/lib/mock-data/mock-form-fields.data.ts index 92d324387..f118bc5a6 100644 --- a/packages/davinci-client/src/lib/mock-data/mock-form-fields.data.ts +++ b/packages/davinci-client/src/lib/mock-data/mock-form-fields.data.ts @@ -1,4 +1,4 @@ -const obj = { +export const obj = { interactionId: '18fa40b7-0eb8-4a5c-803c-d3f3f807ed46', companyId: '02fb4743-189a-4bc7-9d6c-a919edfe6447', connectionId: '8209285e0d2f3fc76bfd23fd10d45e6f', diff --git a/packages/davinci-client/tsconfig.json b/packages/davinci-client/tsconfig.json index 91ceb908d..eefb01564 100644 --- a/packages/davinci-client/tsconfig.json +++ b/packages/davinci-client/tsconfig.json @@ -6,7 +6,8 @@ "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "resolveJsonModule": true }, "references": [ { diff --git a/packages/davinci-client/tsconfig.lib.json b/packages/davinci-client/tsconfig.lib.json index 562809b65..dcee077a8 100644 --- a/packages/davinci-client/tsconfig.lib.json +++ b/packages/davinci-client/tsconfig.lib.json @@ -22,6 +22,7 @@ "vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", + "src/**/*.test-d.ts", "src/lib/mock-data/*" ] } diff --git a/packages/davinci-client/tsconfig.spec.json b/packages/davinci-client/tsconfig.spec.json index c788fc13e..ea6fd1ab8 100644 --- a/packages/davinci-client/tsconfig.spec.json +++ b/packages/davinci-client/tsconfig.spec.json @@ -2,17 +2,13 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "NodeNext", - "outDir": "../../dist/out-tsc", - "composite": true, + "outDir": "./dist", + "declaration": true, + "declarationMap": true, "moduleResolution": "NodeNext", + "resolveJsonModule": true, "target": "ESNext", - "types": [ - "vitest/vitest", - "vitest/globals", - "vitest/importMeta", - "vite/client", - "node" - ] + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] }, "include": [ "src/**/*.ts", diff --git a/packages/davinci-client/vite.config.ts b/packages/davinci-client/vite.config.ts index 904e32ca2..41f47d680 100644 --- a/packages/davinci-client/vite.config.ts +++ b/packages/davinci-client/vite.config.ts @@ -1,7 +1,6 @@ import { defineConfig } from 'vite'; import dts from 'vite-plugin-dts'; import * as path from 'path'; -import * as pkg from './package.json'; import { codecovVitePlugin } from '@codecov/vite-plugin'; export default defineConfig({ @@ -32,13 +31,6 @@ export default defineConfig({ preserveModules: true, preserveModulesRoot: 'src', }, - external: Array.from(Object.keys(pkg.dependencies) || []).concat([ - './src/lib/mock-data/*', - '@reduxjs/toolkit/query', - '@forgerock/javascript-sdk', - '@forgerock/javascript-sdk/src/oauth2-client/state-pkce', - 'javascript-sdk', - ]), }, lib: { entry: 'src/index.ts', @@ -57,6 +49,7 @@ export default defineConfig({ dir: '../../node_modules/.vitest', }, typecheck: { + enabled: true, include: ['src/**/*.test-d.{ts,tsx}'], }, globals: true, diff --git a/packages/device-client/.eslintignore b/packages/device-client/.eslintignore index 288d66ab2..309688b91 100644 --- a/packages/device-client/.eslintignore +++ b/packages/device-client/.eslintignore @@ -9,3 +9,4 @@ dist docs coverage vite.config.*.timestamp* +*tsconfig.tsbuildinfo* diff --git a/packages/device-client/.eslintrc.json b/packages/device-client/.eslintrc.json index 3fc5707da..28346c7fe 100644 --- a/packages/device-client/.eslintrc.json +++ b/packages/device-client/.eslintrc.json @@ -19,7 +19,7 @@ "parser": "jsonc-eslint-parser", "rules": { "@nx/dependency-checks": [ - "error", + "warn", { "ignoredFiles": [ "{projectRoot}/eslint.config.{js,cjs,mjs}", diff --git a/packages/device-client/package.json b/packages/device-client/package.json index 74de31495..859a3fcfc 100644 --- a/packages/device-client/package.json +++ b/packages/device-client/package.json @@ -15,19 +15,11 @@ "files": ["./dist"], "dependencies": { "@reduxjs/toolkit": "catalog:", - "@forgerock/javascript-sdk": "4.6.0", - "immer": "catalog:" + "@forgerock/javascript-sdk": "4.6.0" }, "devDependencies": { "msw": "^2.5.1" }, - "scripts": { - "build": "nx exec -- tsc --project ./tsconfig.lib.json", - "test": "vitest", - "test:watch": "vitest --watch", - "test:coverage": "vitest --coverage", - "lint": "nx exec -- eslint **/*.ts --fix" - }, "nx": { "targets": { "build": { diff --git a/packages/device-client/tsconfig.spec.json b/packages/device-client/tsconfig.spec.json index 0e527c9e6..9e6c46079 100644 --- a/packages/device-client/tsconfig.spec.json +++ b/packages/device-client/tsconfig.spec.json @@ -6,13 +6,7 @@ "moduleResolution": "NodeNext", "target": "ESNext", "outDir": "../../dist/out-tsc", - "types": [ - "vitest/vitest", - "vitest/globals", - "vitest/importMeta", - "vite/client", - "node" - ] + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] }, "include": [ "vite.config.ts", diff --git a/packages/device-client/vite.config.ts b/packages/device-client/vite.config.ts index b5da742d3..537f24c6c 100644 --- a/packages/device-client/vite.config.ts +++ b/packages/device-client/vite.config.ts @@ -46,7 +46,6 @@ export default defineConfig(() => ({ reportsDirectory: './coverage', provider: 'v8', }, - deps: { optimizer: { web: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 15122f793..942b8bef5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -117,10 +117,10 @@ importers: specifier: ^8.13.0 version: 8.18.0(eslint@8.57.0)(typescript@5.7.3) '@vitest/coverage-v8': - specifier: ^3.0.4 + specifier: 3.0.4 version: 3.0.4(vitest@3.0.4) '@vitest/ui': - specifier: ^3.0.4 + specifier: 3.0.4 version: 3.0.4(vitest@3.0.4) conventional-changelog-conventionalcommits: specifier: ^7.0.2 @@ -222,7 +222,7 @@ importers: specifier: ^4.3.2 version: 4.3.2(typescript@5.7.3)(vite@5.4.8(@types/node@22.10.2)(less@4.1.3)(sass@1.75.0)(stylus@0.64.0)(terser@5.33.0)) vitest: - specifier: ^3.0.4 + specifier: 3.0.4 version: 3.0.4(@types/node@22.10.2)(@vitest/ui@3.0.4)(jsdom@22.1.0)(less@4.1.3)(msw@2.5.1(@types/node@22.10.2)(typescript@5.7.3))(sass@1.75.0)(stylus@0.64.0)(terser@5.33.0) vitest-canvas-mock: specifier: ^0.3.3 @@ -253,9 +253,6 @@ importers: '@effect/schema': specifier: ^0.68.23 version: 0.68.23(effect@3.12.7) - '@effect/vitest': - specifier: ^0.17.3 - version: 0.17.3(effect@3.12.7)(vitest@3.0.4) effect: specifier: ^3.12.7 version: 3.12.7 @@ -265,6 +262,13 @@ importers: effect-http-node: specifier: ^0.16.1 version: 0.16.1(@effect/platform-node@0.53.26(@effect/platform@0.58.27(@effect/schema@0.68.23(effect@3.12.7))(effect@3.12.7))(effect@3.12.7))(@effect/platform@0.58.27(@effect/schema@0.68.23(effect@3.12.7))(effect@3.12.7))(@effect/schema@0.68.23(effect@3.12.7))(effect-http@0.73.0(@effect/platform@0.58.27(@effect/schema@0.68.23(effect@3.12.7))(effect@3.12.7))(@effect/schema@0.68.23(effect@3.12.7))(effect@3.12.7))(effect@3.12.7) + devDependencies: + '@effect/vitest': + specifier: ^0.17.3 + version: 0.17.3(effect@3.12.7)(vitest@3.0.4) + vitest: + specifier: ^3.0.4 + version: 3.0.4(@types/node@22.10.2)(@vitest/ui@3.0.4)(jsdom@22.1.0)(less@4.1.3)(msw@2.5.1(@types/node@22.10.2)(typescript@5.7.3))(sass@1.75.0)(stylus@0.64.0)(terser@5.33.0) packages/davinci-client: dependencies: @@ -277,6 +281,10 @@ importers: immer: specifier: 'catalog:' version: 10.1.1 + devDependencies: + vitest: + specifier: 3.0.4 + version: 3.0.4(@types/node@22.10.2)(@vitest/ui@3.0.4)(jsdom@22.1.0)(less@4.1.3)(msw@2.5.1(@types/node@22.10.2)(typescript@5.7.3))(sass@1.75.0)(stylus@0.64.0)(terser@5.33.0) packages/device-client: dependencies: @@ -286,9 +294,6 @@ importers: '@reduxjs/toolkit': specifier: 'catalog:' version: 2.3.0(react@18.3.1) - immer: - specifier: 'catalog:' - version: 10.1.1 devDependencies: msw: specifier: ^2.5.1 @@ -11058,7 +11063,7 @@ snapshots: agent-base@6.0.2: dependencies: - debug: 4.3.7 + debug: 4.4.0 transitivePeerDependencies: - supports-color @@ -12485,7 +12490,7 @@ snapshots: estree-walker@3.0.3: dependencies: - '@types/estree': 1.0.5 + '@types/estree': 1.0.6 esutils@2.0.3: {} @@ -15816,7 +15821,7 @@ snapshots: stylus@0.64.0: dependencies: '@adobe/css-tools': 4.3.3 - debug: 4.3.7 + debug: 4.4.0 glob: 10.4.5 sax: 1.4.1 source-map: 0.7.4 diff --git a/tools/create-package/src/generators/create-package-generator.test.ts b/tools/create-package/src/generators/create-package-generator.test.ts deleted file mode 100644 index 25a16fb66..000000000 --- a/tools/create-package/src/generators/create-package-generator.test.ts +++ /dev/null @@ -1,214 +0,0 @@ -import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; -import { Tree, installPackagesTask, formatFiles } from '@nx/devkit'; -import { createPackageGeneratorGenerator } from './create-package-generator.js'; -import { CreatePackageGeneratorGeneratorSchema } from './schema.js'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; - -// Mock installPackagesTask and formatFiles -vi.mock('@nx/devkit', async () => { - const actual = await vi.importActual('@nx/devkit'); - return { - ...actual, - installPackagesTask: vi.fn(), - formatFiles: vi.fn(), - }; -}); - -describe('create-package-generator generator', () => { - let tree: Tree; - let options: CreatePackageGeneratorGeneratorSchema = { name: 'test' }; - - beforeEach(() => { - tree = createTreeWithEmptyWorkspace(); - vi.clearAllMocks(); - }); - - const getJson = (path: string) => { - const contents = tree.read(path) ?? new Buffer(''); - const value = Buffer.from(contents).toString(); - - return JSON.parse(value); - }; - - it('should run successfully', async () => { - options = { - name: 'test-package', - packageScope: 'test', - description: 'I have written some code', - sideEffects: false, - outputDir: './dist', - moduleType: 'module', - }; - const returnedFn = await createPackageGeneratorGenerator(tree, options); - - expect(tree.exists('packages/test-package/package.json')).toBeTruthy(); - - const packageJson = getJson('packages/test-package/package.json'); - - expect(packageJson.name).toBe('@test/test-package'); - expect(packageJson.sideEffects).toBe(false); - expect(packageJson.type).toBe('module'); - expect(packageJson.description).toBe('I have written some code'); - expect(packageJson.module).toBe('./dist/index.js'); - expect(packageJson.exports).toEqual({ - '.': './dist/index.js', - './package.json': './package.json', - }); - expect(packageJson.dependencies).toEqual({}); - expect(packageJson.devDependencies).toEqual({}); - expect(packageJson.version).toBe('0.0.0'); - expect(packageJson.private).toBe(true); - expect(packageJson.main).toBe('./dist/index.js'); - - expect(tree.exists('packages/test-package/src/index.ts')).toBe(true); - expect(tree.exists('packages/test-package/src/lib/index.ts')).toBe(true); - expect(tree.exists('packages/test-package/LICENSE')).toBe(true); - - expect(typeof returnedFn).toBe('function'); - - returnedFn(); - expect(installPackagesTask).toHaveBeenCalledTimes(1); - expect(installPackagesTask).toHaveBeenCalledWith(tree, true); - }); - - it('should have defaults that work', async () => { - options = { - name: 'test-package', - }; - const installer = await createPackageGeneratorGenerator(tree, options); - - expect(tree.exists('packages/test-package/package.json')).toBeTruthy(); - - const packageJson = getJson('packages/test-package/package.json'); - - expect(packageJson.name).toBe('@forgerock/test-package'); - expect(packageJson.sideEffects).toBe(false); - expect(packageJson.type).toBe('module'); - expect(packageJson.description).toBe(''); - expect(packageJson.module).toBe('./dist/index.js'); - expect(packageJson.exports).toEqual({ - '.': './dist/index.js', - './package.json': './package.json', - }); - expect(packageJson.dependencies).toEqual({}); - expect(packageJson.devDependencies).toEqual({}); - expect(packageJson.version).toBe('0.0.0'); - expect(packageJson.private).toBe(true); - expect(packageJson.main).toBe('./dist/index.js'); - - expect(tree.exists('packages/test-package/src/index.ts')).toBe(true); - expect(tree.exists('packages/test-package/src/lib/index.ts')).toBe(true); - expect(tree.exists('packages/test-package/LICENSE')).toBe(true); - - installer(); - expect(installPackagesTask).toHaveBeenCalledWith(tree, true); - }); - - describe('installer function', () => { - it('should handle installation errors', async () => { - vi.mocked(installPackagesTask).mockImplementationOnce(() => { - throw new Error('Installation failed'); - }); - - const installer = await createPackageGeneratorGenerator(tree, { name: 'test-package' }); - expect(() => installer()).toThrow('Installation failed'); - }); - - it('should handle multiple installations', async () => { - const installer = await createPackageGeneratorGenerator(tree, { name: 'test-package' }); - - installer(); - installer(); - - expect(installPackagesTask).toHaveBeenCalledTimes(2); - expect(installPackagesTask).toHaveBeenNthCalledWith(1, tree, true); - expect(installPackagesTask).toHaveBeenNthCalledWith(2, tree, true); - }); - }); - - describe('file content validation', () => { - it('should generate correct index.ts content', async () => { - await createPackageGeneratorGenerator(tree, { name: 'test-package' }); - - const indexContent = tree.read('packages/test-package/src/index.ts')?.toString(); - expect(indexContent).toContain('import testPackage from "./lib/index.ts"'); - }); - - it('should generate correct lib/index.ts content', async () => { - await createPackageGeneratorGenerator(tree, { name: 'test-package' }); - - const libContent = tree.read('packages/test-package/src/lib/index.ts')?.toString(); - expect(libContent).toBeDefined(); - expect(libContent).not.toBe(''); - }); - - it('should include correct license content', async () => { - await createPackageGeneratorGenerator(tree, { name: 'test-package' }); - - const licenseContent = tree.read('packages/test-package/LICENSE')?.toString(); - expect(licenseContent).toBeDefined(); - expect(licenseContent).toContain('MIT License'); - }); - }); - - describe('package.json edge cases', () => { - it('should sanitize package names properly', async () => { - await createPackageGeneratorGenerator(tree, { - name: 'test-package-with-special', - packageScope: 'test-scope', - }); - - const packageJson = getJson('packages/test-package-with-special/package.json'); - expect(packageJson.name).toBe('@test-scope/test-package-with-special'); - }); - - it('should handle very long descriptions', async () => { - const longDescription = 'a'.repeat(1000); - await createPackageGeneratorGenerator(tree, { - name: 'test-package-long-desc', - description: longDescription, - }); - - const packageJson = getJson('packages/test-package-long-desc/package.json'); - expect(packageJson.description).toBe(longDescription); - }); - }); - - describe('file formatting', () => { - it('should call formatFiles after generating files', async () => { - await createPackageGeneratorGenerator(tree, { name: 'test-package' }); - expect(formatFiles).toHaveBeenCalledTimes(1); - expect(formatFiles).toHaveBeenCalledWith(tree); - }); - - it('should still create files if formatFiles fails', async () => { - vi.mocked(formatFiles).mockRejectedValueOnce(new Error('Format failed')); - - await expect(createPackageGeneratorGenerator(tree, { name: 'test-package' })).rejects.toThrow( - 'Format failed', - ); - - expect(tree.exists('packages/test-package/package.json')).toBe(true); - }); - }); - - it('should error if no name is passed', async () => { - const options = {}; - // @ts-expect-error options is purposefully invalid - await expect(createPackageGeneratorGenerator(tree, options)).rejects.toThrowError( - 'Invalid name provided. Please provide a name', - ); - }); - - it('should error when no moduleType is provided or its invalid', async () => { - const options = { - name: 'test-package', - moduleType: 'invalid moduleType', - }; - - // @ts-expect-error options is purposefully invalid - await expect(createPackageGeneratorGenerator(tree, options)).rejects.toThrowError( - 'Invalid moduleType provided. Please provide a valid moduleType', - ); - }); -}); diff --git a/tsconfig.base.json b/tsconfig.base.json index 9ecd4ab32..1f316f588 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -2,6 +2,7 @@ "compilerOptions": { "composite": true, "declaration": true, - "declarationMap": true + "declarationMap": true, + "skipLibCheck": true } } diff --git a/tsconfig.json b/tsconfig.json index 705fb4abe..48184413d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,9 +4,6 @@ "compilerOptions": {}, "files": [], // intentionally empty "references": [ - { - "path": "./packages/davinci-client" - }, { "path": "./packages/device-client" }, @@ -16,6 +13,11 @@ { "path": "./e2e/davinci-app" }, - {} + { + "path": "./e2e/mock-api-v2" + }, + { + "path": "./packages/davinci-client" + } ] }