diff --git a/packages/nx-set-shas/tsconfig.lib.json b/packages/nx-set-shas/tsconfig.lib.json index e73113a8..57894cf7 100644 --- a/packages/nx-set-shas/tsconfig.lib.json +++ b/packages/nx-set-shas/tsconfig.lib.json @@ -10,7 +10,11 @@ "resolveJsonModule": true }, "include": ["src/**/*.ts"], - "references": [], + "references": [ + { + "path": "../core/tsconfig.lib.json" + } + ], "exclude": [ "vite.config.ts", "vite.config.mts", diff --git a/plugins/nx-graphql-codegen/eslint.config.js b/plugins/nx-graphql-codegen/eslint.config.js index a6236c75..9358844b 100644 --- a/plugins/nx-graphql-codegen/eslint.config.js +++ b/plugins/nx-graphql-codegen/eslint.config.js @@ -8,7 +8,7 @@ module.exports = [ '@nx/dependency-checks': [ 'error', { - ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'], + ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}', '{projectRoot}/vite.config.{js,ts,mjs,mts}'], ignoredDependencies: ['@graphql-codegen/cli', 'ts-node'], }, ], diff --git a/plugins/nx-graphql-codegen/executors.json b/plugins/nx-graphql-codegen/executors.json index 86905ef2..ec249096 100644 --- a/plugins/nx-graphql-codegen/executors.json +++ b/plugins/nx-graphql-codegen/executors.json @@ -1,8 +1,8 @@ { "executors": { "generate": { - "implementation": "./src/executors/generate/executor", - "schema": "./src/executors/generate/schema.json", + "implementation": "./dist/executors/generate/executor", + "schema": "./dist/executors/generate/schema.json", "description": "The generate command generates the data types corresponding to the graphql schema" } } diff --git a/plugins/nx-graphql-codegen/generators.json b/plugins/nx-graphql-codegen/generators.json index 9f233483..4eaae6ad 100644 --- a/plugins/nx-graphql-codegen/generators.json +++ b/plugins/nx-graphql-codegen/generators.json @@ -1,8 +1,8 @@ { "generators": { "configuration": { - "factory": "./src/generators/configuration/generator", - "schema": "./src/generators/configuration/schema.json", + "factory": "./dist/generators/configuration/generator", + "schema": "./dist/generators/configuration/schema.json", "description": "Add graphql-code-generator configuration to project" } } diff --git a/plugins/nx-graphql-codegen/jest.config.ts b/plugins/nx-graphql-codegen/jest.config.ts deleted file mode 100644 index 3d4cd3e1..00000000 --- a/plugins/nx-graphql-codegen/jest.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -export default { - displayName: 'nx-graphql-codegen', - preset: '../../jest.preset.js', - transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: 'test-output/jest/coverage', -}; diff --git a/plugins/nx-graphql-codegen/package.json b/plugins/nx-graphql-codegen/package.json index 7ecd5c47..ba8e9059 100644 --- a/plugins/nx-graphql-codegen/package.json +++ b/plugins/nx-graphql-codegen/package.json @@ -21,6 +21,8 @@ }, "files": [ "dist", - "!**/*.tsbuildinfo" + "!**/*.tsbuildinfo", + "generators.json", + "executors.json" ] } diff --git a/plugins/nx-graphql-codegen/project.json b/plugins/nx-graphql-codegen/project.json index 51fa9072..f181f92b 100644 --- a/plugins/nx-graphql-codegen/project.json +++ b/plugins/nx-graphql-codegen/project.json @@ -24,19 +24,16 @@ "input": "./plugins/nx-graphql-codegen/src", "glob": "**/*.d.ts", "output": "." - }, - { - "input": "./plugins/nx-graphql-codegen", - "glob": "generators.json", - "output": "." - }, - { - "input": "./plugins/nx-graphql-codegen", - "glob": "executors.json", - "output": "." } ] } + }, + "test": { + "executor": "@nx/vite:test", + "outputs": ["{options.reportsDirectory}"], + "options": { + "reportsDirectory": "../../coverage/plugins/nx-graphql-codegen" + } } } } diff --git a/plugins/nx-graphql-codegen/src/executors/generate/executor.spec.ts b/plugins/nx-graphql-codegen/src/executors/generate/executor.spec.ts index 95c8dbc5..6e81a139 100644 --- a/plugins/nx-graphql-codegen/src/executors/generate/executor.spec.ts +++ b/plugins/nx-graphql-codegen/src/executors/generate/executor.spec.ts @@ -3,12 +3,10 @@ import { ExecutorContext } from '@nx/devkit'; import executor from './executor'; import { GenerateExecutorSchema } from './schema'; -jest.mock('@nx-tools/core', () => { - const originalModule = jest.requireActual('@nx-tools/core'); +vi.mock('@nx-tools/core', async (importOriginal) => { return { - __esModule: true, - ...originalModule, - getExecOutput: jest.fn(async () => Promise.resolve({ stderr: '', exitCode: 0 })), + ...(await importOriginal()), + getExecOutput: vi.fn(async () => Promise.resolve({ stderr: '', exitCode: 0 })), }; }); @@ -26,7 +24,7 @@ export const expectCommandToHaveBeenCalled = (cmd: string, args: string[]) => { describe('Generate Executor', () => { beforeEach(() => { - jest.spyOn(console, 'info').mockImplementation(() => true); + vi.spyOn(console, 'info').mockImplementation(() => true); }); it('can run with empty options', async () => { diff --git a/plugins/nx-graphql-codegen/tsconfig.lib.json b/plugins/nx-graphql-codegen/tsconfig.lib.json index d7a99538..693adfdc 100644 --- a/plugins/nx-graphql-codegen/tsconfig.lib.json +++ b/plugins/nx-graphql-codegen/tsconfig.lib.json @@ -14,5 +14,18 @@ "path": "../../packages/core/tsconfig.lib.json" } ], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] + "exclude": [ + "vite.config.ts", + "vite.config.mts", + "vitest.config.ts", + "vitest.config.mts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx" + ] } diff --git a/plugins/nx-graphql-codegen/tsconfig.spec.json b/plugins/nx-graphql-codegen/tsconfig.spec.json index c67ac295..8c71d9e6 100644 --- a/plugins/nx-graphql-codegen/tsconfig.spec.json +++ b/plugins/nx-graphql-codegen/tsconfig.spec.json @@ -1,10 +1,24 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "./out-tsc/jest", - "types": ["jest", "node"] + "outDir": "./out-tsc/vitest", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"] }, - "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"], + "include": [ + "vite.config.ts", + "vite.config.mts", + "vitest.config.ts", + "vitest.config.mts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ], "references": [ { "path": "./tsconfig.lib.json" diff --git a/plugins/nx-graphql-codegen/vite.config.ts b/plugins/nx-graphql-codegen/vite.config.ts new file mode 100644 index 00000000..4b31c3e8 --- /dev/null +++ b/plugins/nx-graphql-codegen/vite.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + root: __dirname, + cacheDir: '../../node_modules/.vite/plugins/nx-graphql-codegen', + plugins: [], + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + test: { + watch: false, + globals: true, + environment: 'jsdom', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + reporters: ['default'], + coverage: { reportsDirectory: '../../coverage/plugins/nx-graphql-codegen', provider: 'v8' }, + }, +});