Skip to content

Commit

Permalink
build: work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
khalilou88 committed Oct 6, 2023
1 parent eb69227 commit f443787
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 46 deletions.
21 changes: 7 additions & 14 deletions packages/internal/testing/src/lib/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as path from 'path';

import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFiles,
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('nx-boot-maven e2e', () => {
xmlDistAbsolutePath,
);

addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath);
addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
2 changes: 2 additions & 0 deletions testing-projects/e2e/nx-gradle-e2e/tests/nx-gradle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkstyleVersion } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
patchPackageJson,
patchRootPackageJson,
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('nx-gradle e2e', () => {
gradleDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxGradleDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as path from 'path';

import { checkstyleVersion } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
patchPackageJson,
patchRootPackageJson,
Expand Down Expand Up @@ -82,6 +83,7 @@ describe('nx-gradle kotlin dsl e2e', () => {
gradleDistAbsolutePath,
);

addPrettierToPackageJsonFile(nxGradleDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
4 changes: 2 additions & 2 deletions testing-projects/e2e/nx-maven-e2e/tests/nx-maven.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFiles,
addPrettierToPackageJsonFile,
addSpringBootVersion,
addTmpToGitignore,
getData,
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('nx-maven e2e', () => {
xmlDistAbsolutePath,
);

addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath);
addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as path from 'path';

import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addPrettierToPackageJsonFiles,
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('nx-micronaut-maven e2e', () => {
xmlDistAbsolutePath,
);

addPrettierToPackageJsonFiles(nxBootMavenDistAbsolutePath);
addPrettierToPackageJsonFile(nxBootMavenDistAbsolutePath);
runPackageManagerInstallLinks();

await runNxCommandAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as path from 'path';
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addJVMMemory,
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as path from 'path';
import { checkstyleVersion, normalizeName } from '@jnxplus/common';
import {
addJVMMemory,
addPrettierToPackageJsonFile,
addTmpToGitignore,
checkFilesDoNotExist,
getData,
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down
Loading

0 comments on commit f443787

Please sign in to comment.