diff --git a/packages/nx-ktor/src/generators/project/lib/generate-ktor-project.ts b/packages/nx-ktor/src/generators/project/lib/generate-ktor-project.ts index 6fe982dc..f925ffb0 100644 --- a/packages/nx-ktor/src/generators/project/lib/generate-ktor-project.ts +++ b/packages/nx-ktor/src/generators/project/lib/generate-ktor-project.ts @@ -1,4 +1,10 @@ -import { Tree, joinPathFragments, logger, stripIndents, workspaceRoot } from '@nx/devkit'; +import { + Tree, + joinPathFragments, + logger, + stripIndents, + workspaceRoot, +} from '@nx/devkit'; import fetch from 'node-fetch'; import { NormalizedSchema } from '../schema'; @@ -6,7 +12,7 @@ import { buildKtorDownloadUrl } from '../../../utils/ktor-utils'; import { NX_KTOR_PKG } from '../../../index'; import { extractFromZipStream, - getCommonHttpHeaders, + getCommonHttpHeaders, getGradleWrapperFiles, getMavenWrapperFiles, } from '@nxrocks/common-jvm'; @@ -35,7 +41,10 @@ export async function generateKtorProject( const response = await fetch(downloadUrl, downloadOptions); logger.info( - `📦 Extracting Ktor project zip to '${joinPathFragments(workspaceRoot, options.projectRoot)}'...` + `📦 Extracting Ktor project zip to '${joinPathFragments( + workspaceRoot, + options.projectRoot + )}'...` ); if (response.ok) { @@ -44,20 +53,25 @@ export async function generateKtorProject( entryPath.endsWith('mvnw') || entryPath.endsWith('gradlew') ? '755' : undefined; - if (getMavenWrapperFiles().includes(entryPath) || getGradleWrapperFiles().includes(entryPath)) { + if ( + getMavenWrapperFiles().includes(entryPath) || + getGradleWrapperFiles().includes(entryPath) + ) { if (options.transformIntoMultiModule) { tree.write(`${options.moduleRoot}/${entryPath}`, entryContent, { mode: execPermission, }); } - if (options.keepProjectLevelWrapper) { + if ( + (options.transformIntoMultiModule || + options.addToExistingParentModule) && + options.keepProjectLevelWrapper + ) { tree.write(`${options.projectRoot}/${entryPath}`, entryContent, { mode: execPermission, }); } - - } - else { + } else { tree.write(`${options.projectRoot}/${entryPath}`, entryContent, { mode: execPermission, }); @@ -65,8 +79,9 @@ export async function generateKtorProject( }); } else { throw new Error(stripIndents` - ❌ Error downloading Ktor project zip from '${options.ktorInitializrUrl - }' + ❌ Error downloading Ktor project zip from '${ + options.ktorInitializrUrl + }' If the problem persists, please open an issue at https://github.com/tinesoft/nxrocks/issues, with the following information: ------------------------------------------------------ Download URL: ${downloadUrl} diff --git a/packages/nx-micronaut/src/generators/project/lib/generate-micronaut-project.ts b/packages/nx-micronaut/src/generators/project/lib/generate-micronaut-project.ts index f18e3f93..7615600d 100644 --- a/packages/nx-micronaut/src/generators/project/lib/generate-micronaut-project.ts +++ b/packages/nx-micronaut/src/generators/project/lib/generate-micronaut-project.ts @@ -1,4 +1,10 @@ -import { Tree, joinPathFragments, logger, stripIndents, workspaceRoot } from '@nx/devkit'; +import { + Tree, + joinPathFragments, + logger, + stripIndents, + workspaceRoot, +} from '@nx/devkit'; import fetch from 'node-fetch'; import { NormalizedSchema } from '../schema'; @@ -27,7 +33,10 @@ export async function generateMicronautProject( ); logger.info( - `📦 Extracting Micronaut project zip to '${joinPathFragments(workspaceRoot, options.projectRoot)}'...` + `📦 Extracting Micronaut project zip to '${joinPathFragments( + workspaceRoot, + options.projectRoot + )}'...` ); if (response.ok) { @@ -40,20 +49,25 @@ export async function generateMicronautProject( filePath.endsWith('mvnw') || filePath.endsWith('gradlew') ? '755' : undefined; - if (getMavenWrapperFiles().includes(filePath) || getGradleWrapperFiles().includes(filePath)) { + if ( + getMavenWrapperFiles().includes(filePath) || + getGradleWrapperFiles().includes(filePath) + ) { if (options.transformIntoMultiModule) { tree.write(`${options.moduleRoot}/${filePath}`, entryContent, { mode: execPermission, }); } - if (options.keepProjectLevelWrapper) { + if ( + (options.transformIntoMultiModule || + options.addToExistingParentModule) && + options.keepProjectLevelWrapper + ) { tree.write(`${options.projectRoot}/${filePath}`, entryContent, { mode: execPermission, }); } - - } - else { + } else { tree.write(`${options.projectRoot}/${filePath}`, entryContent, { mode: execPermission, }); @@ -61,8 +75,9 @@ export async function generateMicronautProject( }); } else { throw new Error(stripIndents` - ❌ Error downloading Micronaut project zip from '${options.micronautLaunchUrl - }' + ❌ Error downloading Micronaut project zip from '${ + options.micronautLaunchUrl + }' If the problem persists, please open an issue at https://github.com/tinesoft/nxrocks/issues, with the following information: ------------------------------------------------------ Download URL: ${downloadUrl} diff --git a/packages/nx-quarkus/src/generators/project/lib/generate-quarkus-project.ts b/packages/nx-quarkus/src/generators/project/lib/generate-quarkus-project.ts index b2eccb04..1f5cda77 100644 --- a/packages/nx-quarkus/src/generators/project/lib/generate-quarkus-project.ts +++ b/packages/nx-quarkus/src/generators/project/lib/generate-quarkus-project.ts @@ -1,4 +1,10 @@ -import { Tree, joinPathFragments, logger, stripIndents, workspaceRoot } from '@nx/devkit'; +import { + Tree, + joinPathFragments, + logger, + stripIndents, + workspaceRoot, +} from '@nx/devkit'; import fetch from 'node-fetch'; import { NormalizedSchema } from '../schema'; @@ -25,7 +31,10 @@ export async function generateQuarkusProject( ); logger.info( - `📦 Extracting Quarkus project zip to '${joinPathFragments(workspaceRoot, options.projectRoot)}'...` + `📦 Extracting Quarkus project zip to '${joinPathFragments( + workspaceRoot, + options.projectRoot + )}'...` ); if (response.ok) { @@ -35,20 +44,25 @@ export async function generateQuarkusProject( filePath.endsWith('mvnw') || filePath.endsWith('gradlew') ? '755' : undefined; - if (getMavenWrapperFiles().includes(filePath) || getGradleWrapperFiles().includes(filePath)) { + if ( + getMavenWrapperFiles().includes(filePath) || + getGradleWrapperFiles().includes(filePath) + ) { if (options.transformIntoMultiModule) { tree.write(`${options.moduleRoot}/${filePath}`, entryContent, { mode: execPermission, }); } - if (options.keepProjectLevelWrapper) { + if ( + (options.transformIntoMultiModule || + options.addToExistingParentModule) && + options.keepProjectLevelWrapper + ) { tree.write(`${options.projectRoot}/${filePath}`, entryContent, { mode: execPermission, }); } - - } - else { + } else { tree.write(`${options.projectRoot}/${filePath}`, entryContent, { mode: execPermission, }); @@ -56,8 +70,9 @@ export async function generateQuarkusProject( }); } else { throw new Error(stripIndents` - ❌ Error downloading Quarkus project zip from '${options.quarkusInitializerUrl - }' + ❌ Error downloading Quarkus project zip from '${ + options.quarkusInitializerUrl + }' If the problem persists, please open an issue at https://github.com/tinesoft/nxrocks/issues, with the following information: ------------------------------------------------------ Download URL: ${downloadUrl} diff --git a/packages/nx-spring-boot/src/generators/project/lib/generate-boot-project.ts b/packages/nx-spring-boot/src/generators/project/lib/generate-boot-project.ts index 1a8d072e..ea918528 100644 --- a/packages/nx-spring-boot/src/generators/project/lib/generate-boot-project.ts +++ b/packages/nx-spring-boot/src/generators/project/lib/generate-boot-project.ts @@ -1,4 +1,11 @@ -import { Tree, joinPathFragments, logger, names, stripIndents, workspaceRoot } from '@nx/devkit'; +import { + Tree, + joinPathFragments, + logger, + names, + stripIndents, + workspaceRoot, +} from '@nx/devkit'; import fetch from 'node-fetch'; import { NormalizedSchema } from '../schema'; @@ -27,28 +34,41 @@ export async function generateBootProject( ); logger.info( - `📦 Extracting Spring Boot project zip to '${joinPathFragments(workspaceRoot, options.projectRoot)}'...` + `📦 Extracting Spring Boot project zip to '${joinPathFragments( + workspaceRoot, + options.projectRoot + )}'...` ); if (response.ok) { await extractFromZipStream(response.body, (entryPath, entryContent) => { const execPermission = - entryPath.endsWith('mvnw') || entryPath.endsWith('gradlew') ? '755' : undefined; + entryPath.endsWith('mvnw') || entryPath.endsWith('gradlew') + ? '755' + : undefined; - if (getMavenWrapperFiles().includes(entryPath) || getGradleWrapperFiles().includes(entryPath)) { + if ( + getMavenWrapperFiles().includes(entryPath) || + getGradleWrapperFiles().includes(entryPath) + ) { if (options.transformIntoMultiModule) { tree.write(`${options.moduleRoot}/${entryPath}`, entryContent, { mode: execPermission, }); } - if (options.keepProjectLevelWrapper) { + if ( + (options.transformIntoMultiModule || + options.addToExistingParentModule) && + options.keepProjectLevelWrapper + ) { tree.write(`${options.projectRoot}/${entryPath}`, entryContent, { mode: execPermission, }); } - - } - else if (options.projectType !== 'library' || !getBootApplicationOnlyFiles(options).includes(entryPath)) { + } else if ( + options.projectType !== 'library' || + !getBootApplicationOnlyFiles(options).includes(entryPath) + ) { tree.write(`${options.projectRoot}/${entryPath}`, entryContent, { mode: execPermission, }); @@ -56,8 +76,9 @@ export async function generateBootProject( }); } else { throw new Error(stripIndents` - ❌ Error downloading Spring Boot project zip from '${options.springInitializerUrl - }' + ❌ Error downloading Spring Boot project zip from '${ + options.springInitializerUrl + }' If the problem persists, please open an issue at https://github.com/tinesoft/nxrocks/issues, with the following information: ------------------------------------------------------ Download URL: ${downloadUrl} @@ -68,14 +89,21 @@ export async function generateBootProject( } } - function getBootApplicationOnlyFiles(options: NormalizedSchema) { - const basePath = options.packageName?.replaceAll('.', '/'); - const ext = options.language === 'kotlin' ? '.kt' : options.language === 'groovy' ? '.groovy' : '.java'; + const ext = + options.language === 'kotlin' + ? '.kt' + : options.language === 'groovy' + ? '.groovy' + : '.java'; return [ `src/main/resources/application.properties`, - `src/main/${options.language}/${basePath}/${names(options.name).className}Application${ext}`, - `src/test/${options.language}/${basePath}/${names(options.name).className}ApplicationTests${ext}`]; - -} \ No newline at end of file + `src/main/${options.language}/${basePath}/${ + names(options.name).className + }Application${ext}`, + `src/test/${options.language}/${basePath}/${ + names(options.name).className + }ApplicationTests${ext}`, + ]; +}