From 0162a96b0da4596fa443626647a00c4ce165aabc Mon Sep 17 00:00:00 2001 From: Zachary Williams Date: Sat, 2 Jul 2022 11:34:20 -0500 Subject: [PATCH] fix: vue 2.7 typescript fork-ts issue (#264) --- apps/docusaurus-e2e/tests/docusaurus.test.ts | 2 +- apps/nuxt-e2e/tests/nuxt.test.ts | 2 +- apps/vite-e2e/tests/vite.spec.ts | 2 +- apps/vue-e2e/tests/utils.ts | 2 +- apps/vue-e2e/tests/vue-2.test.ts | 2 +- apps/vue-e2e/tests/vue-3.test.ts | 2 +- .../testing}/.eslintrc.json | 2 +- libs/shared/testing/README.md | 7 ++++ .../testing}/package.json | 2 +- libs/shared/testing/project.json | 15 +++++++++ libs/shared/testing/src/index.ts | 1 + .../testing/src/lib/shared-testing.ts} | 0 .../testing}/tsconfig.json | 5 +-- .../testing}/tsconfig.lib.json | 2 +- libs/test-utils/README.md | 11 ------- libs/test-utils/jest.config.ts | 15 --------- libs/test-utils/project.json | 33 ------------------- libs/test-utils/src/index.ts | 1 - libs/test-utils/tsconfig.spec.json | 9 ----- libs/vue/src/webpack.ts | 4 +-- tsconfig.base.json | 2 +- workspace.json | 2 +- 22 files changed, 37 insertions(+), 86 deletions(-) rename libs/{test-utils => shared/testing}/.eslintrc.json (86%) create mode 100644 libs/shared/testing/README.md rename libs/{test-utils => shared/testing}/package.json (55%) create mode 100644 libs/shared/testing/project.json create mode 100644 libs/shared/testing/src/index.ts rename libs/{test-utils/src/lib/test-utils.ts => shared/testing/src/lib/shared-testing.ts} (100%) rename libs/{test-utils => shared/testing}/tsconfig.json (80%) rename libs/{test-utils => shared/testing}/tsconfig.lib.json (83%) delete mode 100644 libs/test-utils/README.md delete mode 100644 libs/test-utils/jest.config.ts delete mode 100644 libs/test-utils/project.json delete mode 100644 libs/test-utils/src/index.ts delete mode 100644 libs/test-utils/tsconfig.spec.json diff --git a/apps/docusaurus-e2e/tests/docusaurus.test.ts b/apps/docusaurus-e2e/tests/docusaurus.test.ts index 1aeb5fe2..c3b0ed61 100644 --- a/apps/docusaurus-e2e/tests/docusaurus.test.ts +++ b/apps/docusaurus-e2e/tests/docusaurus.test.ts @@ -1,5 +1,5 @@ import { ensureNxProject, uniq } from '@nrwl/nx-plugin/testing'; -import { runNxCommandAsyncStripped } from '@nx-plus/test-utils'; +import { runNxCommandAsyncStripped } from '@nx-plus/shared/testing'; describe('docusaurus e2e', () => { it('should create and build docusaurus', async () => { diff --git a/apps/nuxt-e2e/tests/nuxt.test.ts b/apps/nuxt-e2e/tests/nuxt.test.ts index 7527a957..93f46a02 100644 --- a/apps/nuxt-e2e/tests/nuxt.test.ts +++ b/apps/nuxt-e2e/tests/nuxt.test.ts @@ -5,7 +5,7 @@ import { uniq, updateFile, } from '@nrwl/nx-plugin/testing'; -import { runNxCommandAsyncStripped } from '@nx-plus/test-utils'; +import { runNxCommandAsyncStripped } from '@nx-plus/shared/testing'; describe('nuxt e2e', () => { beforeAll(() => { diff --git a/apps/vite-e2e/tests/vite.spec.ts b/apps/vite-e2e/tests/vite.spec.ts index 621553d3..95b77842 100644 --- a/apps/vite-e2e/tests/vite.spec.ts +++ b/apps/vite-e2e/tests/vite.spec.ts @@ -6,7 +6,7 @@ import { updateFile, } from '@nrwl/nx-plugin/testing'; import { join } from 'path'; -import { runNxCommandAsyncStripped } from '@nx-plus/test-utils'; +import { runNxCommandAsyncStripped } from '@nx-plus/shared/testing'; describe('vite e2e', () => { it('should create vite app', async () => { diff --git a/apps/vue-e2e/tests/utils.ts b/apps/vue-e2e/tests/utils.ts index 207433e7..a349c6d1 100644 --- a/apps/vue-e2e/tests/utils.ts +++ b/apps/vue-e2e/tests/utils.ts @@ -1,7 +1,7 @@ import { tags } from '@angular-devkit/core'; import { checkFilesExist, tmpProjPath } from '@nrwl/nx-plugin/testing'; import * as cp from 'child_process'; -import { runNxCommandAsyncStripped } from '@nx-plus/test-utils'; +import { runNxCommandAsyncStripped } from '@nx-plus/shared/testing'; export async function testGeneratedApp( appName: string, diff --git a/apps/vue-e2e/tests/vue-2.test.ts b/apps/vue-e2e/tests/vue-2.test.ts index c916f665..b9f7070e 100644 --- a/apps/vue-e2e/tests/vue-2.test.ts +++ b/apps/vue-e2e/tests/vue-2.test.ts @@ -6,7 +6,7 @@ import { updateFile, } from '@nrwl/nx-plugin/testing'; import { runNxProdCommandAsync, testGeneratedApp } from './utils'; -import { runNxCommandAsyncStripped } from '@nx-plus/test-utils'; +import { runNxCommandAsyncStripped } from '@nx-plus/shared/testing'; describe('vue 2 e2e', () => { describe('app', () => { diff --git a/apps/vue-e2e/tests/vue-3.test.ts b/apps/vue-e2e/tests/vue-3.test.ts index 64028ed0..42916735 100644 --- a/apps/vue-e2e/tests/vue-3.test.ts +++ b/apps/vue-e2e/tests/vue-3.test.ts @@ -6,7 +6,7 @@ import { updateFile, } from '@nrwl/nx-plugin/testing'; import { runNxProdCommandAsync, testGeneratedApp } from './utils'; -import { runNxCommandAsyncStripped } from '@nx-plus/test-utils'; +import { runNxCommandAsyncStripped } from '@nx-plus/shared/testing'; describe('vue 3 e2e', () => { describe('app', () => { diff --git a/libs/test-utils/.eslintrc.json b/libs/shared/testing/.eslintrc.json similarity index 86% rename from libs/test-utils/.eslintrc.json rename to libs/shared/testing/.eslintrc.json index 9d9c0db5..3456be9b 100644 --- a/libs/test-utils/.eslintrc.json +++ b/libs/shared/testing/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/libs/shared/testing/README.md b/libs/shared/testing/README.md new file mode 100644 index 00000000..fae3840a --- /dev/null +++ b/libs/shared/testing/README.md @@ -0,0 +1,7 @@ +# shared-testing + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build shared-testing` to build the library. diff --git a/libs/test-utils/package.json b/libs/shared/testing/package.json similarity index 55% rename from libs/test-utils/package.json rename to libs/shared/testing/package.json index 8075a14a..e86a86d3 100644 --- a/libs/test-utils/package.json +++ b/libs/shared/testing/package.json @@ -1,5 +1,5 @@ { - "name": "@nx-plus/test-utils", + "name": "@nx-plus/shared/testing", "version": "0.0.1", "type": "commonjs" } diff --git a/libs/shared/testing/project.json b/libs/shared/testing/project.json new file mode 100644 index 00000000..6df390c0 --- /dev/null +++ b/libs/shared/testing/project.json @@ -0,0 +1,15 @@ +{ + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/shared/testing/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/shared/testing/**/*.ts"] + } + } + }, + "tags": [] +} diff --git a/libs/shared/testing/src/index.ts b/libs/shared/testing/src/index.ts new file mode 100644 index 00000000..37b844a7 --- /dev/null +++ b/libs/shared/testing/src/index.ts @@ -0,0 +1 @@ +export * from './lib/shared-testing'; diff --git a/libs/test-utils/src/lib/test-utils.ts b/libs/shared/testing/src/lib/shared-testing.ts similarity index 100% rename from libs/test-utils/src/lib/test-utils.ts rename to libs/shared/testing/src/lib/shared-testing.ts diff --git a/libs/test-utils/tsconfig.json b/libs/shared/testing/tsconfig.json similarity index 80% rename from libs/test-utils/tsconfig.json rename to libs/shared/testing/tsconfig.json index f5b85657..f2400abe 100644 --- a/libs/test-utils/tsconfig.json +++ b/libs/shared/testing/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, @@ -14,9 +14,6 @@ "references": [ { "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" } ] } diff --git a/libs/test-utils/tsconfig.lib.json b/libs/shared/testing/tsconfig.lib.json similarity index 83% rename from libs/test-utils/tsconfig.lib.json rename to libs/shared/testing/tsconfig.lib.json index e85ef50f..4403f2ac 100644 --- a/libs/test-utils/tsconfig.lib.json +++ b/libs/shared/testing/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": [] }, diff --git a/libs/test-utils/README.md b/libs/test-utils/README.md deleted file mode 100644 index 21a3564d..00000000 --- a/libs/test-utils/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# test-utils - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build test-utils` to build the library. - -## Running unit tests - -Run `nx test test-utils` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/test-utils/jest.config.ts b/libs/test-utils/jest.config.ts deleted file mode 100644 index c46c599e..00000000 --- a/libs/test-utils/jest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'test-utils', - preset: '../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/libs/test-utils', -}; diff --git a/libs/test-utils/project.json b/libs/test-utils/project.json deleted file mode 100644 index e8ec9c47..00000000 --- a/libs/test-utils/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/test-utils/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nrwl/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/test-utils", - "main": "libs/test-utils/src/index.ts", - "tsConfig": "libs/test-utils/tsconfig.lib.json", - "assets": ["libs/test-utils/*.md"] - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/test-utils/**/*.ts"] - } - }, - "test": { - "executor": "@nrwl/jest:jest", - "outputs": ["coverage/libs/test-utils"], - "options": { - "jestConfig": "libs/test-utils/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": [] -} diff --git a/libs/test-utils/src/index.ts b/libs/test-utils/src/index.ts deleted file mode 100644 index 1bf4db00..00000000 --- a/libs/test-utils/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/test-utils'; diff --git a/libs/test-utils/tsconfig.spec.json b/libs/test-utils/tsconfig.spec.json deleted file mode 100644 index 546f1287..00000000 --- a/libs/test-utils/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] -} diff --git a/libs/vue/src/webpack.ts b/libs/vue/src/webpack.ts index 96510e20..0d2a52d9 100644 --- a/libs/vue/src/webpack.ts +++ b/libs/vue/src/webpack.ts @@ -36,7 +36,7 @@ export function modifyTsConfigPaths( ): void { const tsConfigPath = path.join(context.root, options.tsConfig); const vue = loadModule('vue', context.root); - const isVue3 = semver.major(vue.version) === 3; + const isVue3orVue2_7 = semver.satisfies(vue.version, '>=2.7.0'); config.module .rule('ts') @@ -53,7 +53,7 @@ export function modifyTsConfigPaths( return loaderOptions; }); config.plugin('fork-ts-checker').tap((args: ANY) => { - if (isVue3) { + if (isVue3orVue2_7) { args[0].typescript.configFile = tsConfigPath; } else { args[0].tsconfig = tsConfigPath; diff --git a/tsconfig.base.json b/tsconfig.base.json index e675d74e..72d02a23 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -34,7 +34,7 @@ "paths": { "@nx-plus/docusaurus": ["libs/docusaurus/src/index.ts"], "@nx-plus/nuxt": ["libs/nuxt/src/index.ts"], - "@nx-plus/test-utils": ["libs/test-utils/src/index.ts"], + "@nx-plus/shared/testing": ["libs/shared/testing/src/index.ts"], "@nx-plus/vite": ["libs/vite/src/index.ts"], "@nx-plus/vue": ["libs/vue/src/index.ts"] } diff --git a/workspace.json b/workspace.json index 172288f1..e7a42b36 100644 --- a/workspace.json +++ b/workspace.json @@ -5,7 +5,7 @@ "docusaurus-e2e": "apps/docusaurus-e2e", "nuxt": "libs/nuxt", "nuxt-e2e": "apps/nuxt-e2e", - "test-utils": "libs/test-utils", + "shared-testing": "libs/shared/testing", "vite": "libs/vite", "vite-e2e": "apps/vite-e2e", "vue": "libs/vue",