From f443787cb8f5e00db1e740711956e58aeb5b11e4 Mon Sep 17 00:00:00 2001 From: khalilou88 Date: Fri, 6 Oct 2023 11:07:13 +0200 Subject: [PATCH] build: work in progress --- packages/internal/testing/src/lib/testing.ts | 21 +++++++------------ .../tests/nx-boot-gradle.spec.ts | 10 +++++---- .../tests/nx-boot-gradle-kt.spec.ts | 10 +++++---- .../tests/nx-boot-maven.spec.ts | 4 ++-- .../e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts | 2 ++ .../tests/nx-gradle-kt.spec.ts | 2 ++ .../e2e/nx-maven-e2e/tests/nx-maven.spec.ts | 4 ++-- .../tests/nx-micronaut-gradle.spec.ts | 10 +++++---- .../tests/nx-micronaut-gradle-kt.spec.ts | 10 +++++---- .../tests/nx-micronaut-maven.spec.ts | 4 ++-- .../tests/nx-quarkus-gradle.spec.ts | 10 +++++---- .../tests/nx-quarkus-gradle-kt.spec.ts | 10 +++++---- .../tests/nx-quarkus-maven.spec.ts | 4 ++-- 13 files changed, 55 insertions(+), 46 deletions(-) diff --git a/packages/internal/testing/src/lib/testing.ts b/packages/internal/testing/src/lib/testing.ts index 3d0ec7c34..44acf52e0 100644 --- a/packages/internal/testing/src/lib/testing.ts +++ b/packages/internal/testing/src/lib/testing.ts @@ -175,20 +175,13 @@ export function patchRootPackageJson( writeJsonFile(path, json); } -export function addPrettierToPackageJsonFiles(pluginDistAbsulutePath: string) { - const path1 = tmpProjPath('package.json'); - const json1 = readJsonFile(path1); - json1.devDependencies['prettier'] = '^3.0.3'; - json1.devDependencies['@prettier/plugin-xml'] = '^3.2.1'; - json1.devDependencies['prettier-plugin-java'] = '^2.3.1'; - writeJsonFile(path1, json1); - - const path2 = path.join(pluginDistAbsulutePath, 'package.json'); - const json2 = readJsonFile(path2); - json2.dependencies['prettier'] = '^3.0.3'; - json2.dependencies['@prettier/plugin-xml'] = '^3.2.1'; - json2.dependencies['prettier-plugin-java'] = '^2.3.1'; - writeJsonFile(path2, json2); +export function addPrettierToPackageJsonFile(pluginDistAbsulutePath: string) { + const packageJsonPath = path.join(pluginDistAbsulutePath, 'package.json'); + const packageJson = readJsonFile(packageJsonPath); + packageJson.dependencies['prettier'] = '^2.8.7'; + packageJson.dependencies['@prettier/plugin-xml'] = '^2.2.0'; + packageJson.dependencies['prettier-plugin-java'] = '^2.1.0'; + writeJsonFile(packageJsonPath, packageJson); } export function patchPackageJson( diff --git a/testing-projects/e2e/nx-boot-gradle-e2e/tests/nx-boot-gradle.spec.ts b/testing-projects/e2e/nx-boot-gradle-e2e/tests/nx-boot-gradle.spec.ts index 8ce7bd8a1..fc342ff07 100644 --- a/testing-projects/e2e/nx-boot-gradle-e2e/tests/nx-boot-gradle.spec.ts +++ b/testing-projects/e2e/nx-boot-gradle-e2e/tests/nx-boot-gradle.spec.ts @@ -13,6 +13,7 @@ import * as fse from 'fs-extra'; import * as path from 'path'; import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -39,7 +40,7 @@ describe('nx-boot-gradle e2e', () => { runNxNewCommand('', true); const pluginName = '@jnxplus/nx-gradle'; - const nxBootGradleDistAbsolutePath = path.join( + const nxGradleDistAbsolutePath = path.join( workspaceRoot, 'dist', 'packages', @@ -61,7 +62,7 @@ describe('nx-boot-gradle e2e', () => { 'gradle-executors', ); - patchRootPackageJson(pluginName, nxBootGradleDistAbsolutePath); + patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); patchRootPackageJson( '@jnxplus/internal-gradle-executors', @@ -75,16 +76,17 @@ describe('nx-boot-gradle e2e', () => { ); patchPackageJson( - nxBootGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/common', commonDistAbsolutePath, ); patchPackageJson( - nxBootGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/internal-gradle-executors', gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-boot-gradle-kt-e2e/tests/nx-boot-gradle-kt.spec.ts b/testing-projects/e2e/nx-boot-gradle-kt-e2e/tests/nx-boot-gradle-kt.spec.ts index f36165dfe..6da3a0433 100644 --- a/testing-projects/e2e/nx-boot-gradle-kt-e2e/tests/nx-boot-gradle-kt.spec.ts +++ b/testing-projects/e2e/nx-boot-gradle-kt-e2e/tests/nx-boot-gradle-kt.spec.ts @@ -14,6 +14,7 @@ import * as path from 'path'; import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -41,7 +42,7 @@ describe('nx-boot-gradle kt e2e', () => { runNxNewCommand('', true); const pluginName = '@jnxplus/nx-gradle'; - const nxBootGradleDistAbsolutePath = path.join( + const nxGradleDistAbsolutePath = path.join( workspaceRoot, 'dist', 'packages', @@ -63,7 +64,7 @@ describe('nx-boot-gradle kt e2e', () => { 'gradle-executors', ); - patchRootPackageJson(pluginName, nxBootGradleDistAbsolutePath); + patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); patchRootPackageJson( '@jnxplus/internal-gradle-executors', @@ -77,16 +78,17 @@ describe('nx-boot-gradle kt e2e', () => { ); patchPackageJson( - nxBootGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/common', commonDistAbsolutePath, ); patchPackageJson( - nxBootGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/internal-gradle-executors', gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-boot-maven-e2e/tests/nx-boot-maven.spec.ts b/testing-projects/e2e/nx-boot-maven-e2e/tests/nx-boot-maven.spec.ts index 692187c70..0ad38d9e2 100644 --- a/testing-projects/e2e/nx-boot-maven-e2e/tests/nx-boot-maven.spec.ts +++ b/testing-projects/e2e/nx-boot-maven-e2e/tests/nx-boot-maven.spec.ts @@ -1,6 +1,6 @@ import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { - addPrettierToPackageJsonFiles, + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -80,7 +80,7 @@ describe('nx-boot-maven e2e', () => { xmlDistAbsolutePath, ); - addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath); + addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts b/testing-projects/e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts index 3fc78d6bf..4037491cb 100644 --- a/testing-projects/e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts +++ b/testing-projects/e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts @@ -1,5 +1,6 @@ import { checkstyleVersion } from '@jnxplus/common'; import { + addPrettierToPackageJsonFile, addTmpToGitignore, patchPackageJson, patchRootPackageJson, @@ -81,6 +82,7 @@ describe('nx-gradle e2e', () => { gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-gradle-kt-e2e/tests/nx-gradle-kt.spec.ts b/testing-projects/e2e/nx-gradle-kt-e2e/tests/nx-gradle-kt.spec.ts index de1ac9c2a..9ce63d4cf 100644 --- a/testing-projects/e2e/nx-gradle-kt-e2e/tests/nx-gradle-kt.spec.ts +++ b/testing-projects/e2e/nx-gradle-kt-e2e/tests/nx-gradle-kt.spec.ts @@ -14,6 +14,7 @@ import * as path from 'path'; import { checkstyleVersion } from '@jnxplus/common'; import { + addPrettierToPackageJsonFile, addTmpToGitignore, patchPackageJson, patchRootPackageJson, @@ -82,6 +83,7 @@ describe('nx-gradle kotlin dsl e2e', () => { gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-maven-e2e/tests/nx-maven.spec.ts b/testing-projects/e2e/nx-maven-e2e/tests/nx-maven.spec.ts index 1d4a73f1a..8c01774ba 100644 --- a/testing-projects/e2e/nx-maven-e2e/tests/nx-maven.spec.ts +++ b/testing-projects/e2e/nx-maven-e2e/tests/nx-maven.spec.ts @@ -1,6 +1,6 @@ import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { - addPrettierToPackageJsonFiles, + addPrettierToPackageJsonFile, addSpringBootVersion, addTmpToGitignore, getData, @@ -80,7 +80,7 @@ describe('nx-maven e2e', () => { xmlDistAbsolutePath, ); - addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath); + addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-micronaut-gradle-e2e/tests/nx-micronaut-gradle.spec.ts b/testing-projects/e2e/nx-micronaut-gradle-e2e/tests/nx-micronaut-gradle.spec.ts index 030aed666..d7300092e 100644 --- a/testing-projects/e2e/nx-micronaut-gradle-e2e/tests/nx-micronaut-gradle.spec.ts +++ b/testing-projects/e2e/nx-micronaut-gradle-e2e/tests/nx-micronaut-gradle.spec.ts @@ -13,6 +13,7 @@ import * as fse from 'fs-extra'; import * as path from 'path'; import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -40,7 +41,7 @@ describe('nx-micronaut-gradle e2e', () => { runNxNewCommand('', true); const pluginName = '@jnxplus/nx-gradle'; - const nxmicronautGradleDistAbsolutePath = path.join( + const nxGradleDistAbsolutePath = path.join( workspaceRoot, 'dist', 'packages', @@ -62,7 +63,7 @@ describe('nx-micronaut-gradle e2e', () => { 'gradle-executors', ); - patchRootPackageJson(pluginName, nxmicronautGradleDistAbsolutePath); + patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); patchRootPackageJson( '@jnxplus/internal-gradle-executors', @@ -76,16 +77,17 @@ describe('nx-micronaut-gradle e2e', () => { ); patchPackageJson( - nxmicronautGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/common', commonDistAbsolutePath, ); patchPackageJson( - nxmicronautGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/internal-gradle-executors', gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-micronaut-gradle-kt-e2e/tests/nx-micronaut-gradle-kt.spec.ts b/testing-projects/e2e/nx-micronaut-gradle-kt-e2e/tests/nx-micronaut-gradle-kt.spec.ts index dc343cedf..353fae4b1 100644 --- a/testing-projects/e2e/nx-micronaut-gradle-kt-e2e/tests/nx-micronaut-gradle-kt.spec.ts +++ b/testing-projects/e2e/nx-micronaut-gradle-kt-e2e/tests/nx-micronaut-gradle-kt.spec.ts @@ -14,6 +14,7 @@ import * as path from 'path'; import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -41,7 +42,7 @@ describe('nx-micronaut-gradle kt e2e', () => { runNxNewCommand('', true); const pluginName = '@jnxplus/nx-gradle'; - const nxmicronautGradleDistAbsolutePath = path.join( + const nxGradleDistAbsolutePath = path.join( workspaceRoot, 'dist', 'packages', @@ -63,7 +64,7 @@ describe('nx-micronaut-gradle kt e2e', () => { 'gradle-executors', ); - patchRootPackageJson(pluginName, nxmicronautGradleDistAbsolutePath); + patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); patchRootPackageJson( '@jnxplus/internal-gradle-executors', @@ -77,16 +78,17 @@ describe('nx-micronaut-gradle kt e2e', () => { ); patchPackageJson( - nxmicronautGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/common', commonDistAbsolutePath, ); patchPackageJson( - nxmicronautGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/internal-gradle-executors', gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-micronaut-maven-e2e/tests/nx-micronaut-maven.spec.ts b/testing-projects/e2e/nx-micronaut-maven-e2e/tests/nx-micronaut-maven.spec.ts index 201d250ea..76d005892 100644 --- a/testing-projects/e2e/nx-micronaut-maven-e2e/tests/nx-micronaut-maven.spec.ts +++ b/testing-projects/e2e/nx-micronaut-maven-e2e/tests/nx-micronaut-maven.spec.ts @@ -1,6 +1,6 @@ import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { - addPrettierToPackageJsonFiles, + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -81,7 +81,7 @@ describe('nx-micronaut-maven e2e', () => { xmlDistAbsolutePath, ); - addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath); + addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-quarkus-gradle-e2e/tests/nx-quarkus-gradle.spec.ts b/testing-projects/e2e/nx-quarkus-gradle-e2e/tests/nx-quarkus-gradle.spec.ts index 012e21b64..f5b97099f 100644 --- a/testing-projects/e2e/nx-quarkus-gradle-e2e/tests/nx-quarkus-gradle.spec.ts +++ b/testing-projects/e2e/nx-quarkus-gradle-e2e/tests/nx-quarkus-gradle.spec.ts @@ -15,6 +15,7 @@ import * as path from 'path'; import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { addJVMMemory, + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -42,7 +43,7 @@ describe('nx-quarkus-gradle e2e', () => { runNxNewCommand('', true); const pluginName = '@jnxplus/nx-gradle'; - const nxQuarkusGradleDistAbsolutePath = path.join( + const nxGradleDistAbsolutePath = path.join( workspaceRoot, 'dist', 'packages', @@ -64,7 +65,7 @@ describe('nx-quarkus-gradle e2e', () => { 'gradle-executors', ); - patchRootPackageJson(pluginName, nxQuarkusGradleDistAbsolutePath); + patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); patchRootPackageJson( '@jnxplus/internal-gradle-executors', @@ -78,16 +79,17 @@ describe('nx-quarkus-gradle e2e', () => { ); patchPackageJson( - nxQuarkusGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/common', commonDistAbsolutePath, ); patchPackageJson( - nxQuarkusGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/internal-gradle-executors', gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-quarkus-gradle-kt-e2e/tests/nx-quarkus-gradle-kt.spec.ts b/testing-projects/e2e/nx-quarkus-gradle-kt-e2e/tests/nx-quarkus-gradle-kt.spec.ts index 4b78e9327..a7f4cf8df 100644 --- a/testing-projects/e2e/nx-quarkus-gradle-kt-e2e/tests/nx-quarkus-gradle-kt.spec.ts +++ b/testing-projects/e2e/nx-quarkus-gradle-kt-e2e/tests/nx-quarkus-gradle-kt.spec.ts @@ -15,6 +15,7 @@ import * as path from 'path'; import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { addJVMMemory, + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -42,7 +43,7 @@ describe('nx-quarkus-gradle kt e2e', () => { runNxNewCommand('', true); const pluginName = '@jnxplus/nx-gradle'; - const nxQuarkusGradleDistAbsolutePath = path.join( + const nxGradleDistAbsolutePath = path.join( workspaceRoot, 'dist', 'packages', @@ -64,7 +65,7 @@ describe('nx-quarkus-gradle kt e2e', () => { 'gradle-executors', ); - patchRootPackageJson(pluginName, nxQuarkusGradleDistAbsolutePath); + patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); patchRootPackageJson( '@jnxplus/internal-gradle-executors', @@ -78,16 +79,17 @@ describe('nx-quarkus-gradle kt e2e', () => { ); patchPackageJson( - nxQuarkusGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/common', commonDistAbsolutePath, ); patchPackageJson( - nxQuarkusGradleDistAbsolutePath, + nxGradleDistAbsolutePath, '@jnxplus/internal-gradle-executors', gradleDistAbsolutePath, ); + addPrettierToPackageJsonFile(nxGradleDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync( diff --git a/testing-projects/e2e/nx-quarkus-maven-e2e/tests/nx-quarkus-maven.spec.ts b/testing-projects/e2e/nx-quarkus-maven-e2e/tests/nx-quarkus-maven.spec.ts index 533de8835..d10c25d68 100644 --- a/testing-projects/e2e/nx-quarkus-maven-e2e/tests/nx-quarkus-maven.spec.ts +++ b/testing-projects/e2e/nx-quarkus-maven-e2e/tests/nx-quarkus-maven.spec.ts @@ -1,6 +1,6 @@ import { checkstyleVersion, normalizeName } from '@jnxplus/common'; import { - addPrettierToPackageJsonFiles, + addPrettierToPackageJsonFile, addTmpToGitignore, checkFilesDoNotExist, getData, @@ -81,7 +81,7 @@ describe('nx-quarkus-maven e2e', () => { xmlDistAbsolutePath, ); - addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath); + addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath); runPackageManagerInstallLinks(); await runNxCommandAsync(