-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into spring-boot-v3
- Loading branch information
Showing
15 changed files
with
430 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
const command = { | ||
configs: { | ||
newFiles: { | ||
description: 'Add new files only', | ||
cli: { | ||
type: Boolean, | ||
}, | ||
scope: 'generator', | ||
}, | ||
convert: { | ||
description: 'Apply Partial Java files to Kotlin files convertion', | ||
cli: { | ||
type: Boolean, | ||
alias: 'c', | ||
}, | ||
scope: 'generator', | ||
}, | ||
}, | ||
import: [], | ||
}; | ||
|
||
export default command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { basename, dirname, join, relative } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import { existsSync } from 'fs'; | ||
import BaseGenerator from 'generator-jhipster/generators/base'; | ||
import { globby } from 'globby'; | ||
import { passthrough } from '@yeoman/transform'; | ||
import { convertToKotlinFile } from '../../generators/kotlin/support/index.js'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
const jhipster8Generators = join(__dirname, '../../node_modules/generator-jhipster/dist/generators'); | ||
|
||
export default class SynchronizeGenerator extends BaseGenerator { | ||
constructor(args, options, features) { | ||
super(args, options, { queueCommandTasks: true, ...features }); | ||
} | ||
|
||
get [BaseGenerator.DEFAULT]() { | ||
return this.asDefaultTaskGroup({ | ||
default() { | ||
if (this.options.convert === false) { | ||
return; | ||
} | ||
this.queueTransformStream( | ||
{ | ||
name: 'convert to kt file', | ||
filter: file => file.path.endsWith('.kt.ejs'), | ||
}, | ||
passthrough(file => { | ||
file.contents = Buffer.from( | ||
file.contents | ||
.toString() | ||
.replaceAll(';\n', '\n') | ||
.replaceAll('\nimport static ', '\nimport ') | ||
.replaceAll('public class ', 'class ') | ||
.replaceAll('.class', '::class') | ||
.replaceAll(/ (?:extends|implements) (\w+)/g, ' : $1') | ||
.replaceAll(/ (?:extends|implements) /g, ' : ') | ||
.replaceAll(/@Override\n(\s*)/g, 'override ') | ||
.replaceAll(/\n( {4})(private |)?(?:final )?(\w+) (\w+)(\n| = )/g, '\n$1$2lateinit var $4: $3$5') | ||
.replaceAll(/private static final (\w+) /g, 'private val ') | ||
.replaceAll(/(?:public |protected )?(\w+) (\w+)\((.*)\) {/g, 'fun $2($3): $1 {') | ||
.replaceAll(': void', ''), | ||
); | ||
}), | ||
); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.asWritingTaskGroup({ | ||
async writing() { | ||
const files = await globby(`${jhipster8Generators}/**/*.java.ejs`); | ||
const ktTemplatesPath = this.destinationPath('generators/spring-boot/templates'); | ||
for (const file of files.filter( | ||
file => !file.includes('/spring-data-couchbase/') && !['GeneratedByJHipster.java.ejs'].includes(basename(file)), | ||
)) { | ||
const relativeDestinationFile = convertToKotlinFile(relative(jhipster8Generators, file)) | ||
.replace('spring-boot/templates/', '') | ||
.replace('server/templates/', '') | ||
.replace(/(?:(?:.*)\/generators\/)?(.*)\/templates/, '$1'); | ||
const destinationFile = join(ktTemplatesPath, relativeDestinationFile); | ||
if (this.options.newFiles !== true || !existsSync(destinationFile)) { | ||
this.copyTemplate(file, destinationFile); | ||
} | ||
} | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export { default } from './generator.js'; | ||
export { default as command } from './command.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
generators/** | ||
generators/*.* | ||
.prettierrc.yml skip | ||
cli/cli.cjs skip | ||
README.md skip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
...andra/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<%# | ||
Copyright 2013-2024 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
Licensed under the Apache License, Version 2.0 (the " | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-%> | ||
package <%= entityAbsolutePackage %>.repository | ||
import <%= entityAbsolutePackage %>.domain.<%= persistClass %> | ||
import org.springframework.data.cassandra.repository.<% if (reactive) { %>Reactive<% } %>CassandraRepository | ||
import org.springframework.stereotype.Repository | ||
<%_ if (primaryKey.typeUUID) { _%> | ||
import java.util.UUID | ||
<%_ } _%> | ||
/** | ||
* <%= springDataDescription %> repository for the <%= persistClass %> entity. | ||
*/ | ||
@Repository | ||
interface <%= entityClass %>Repository: <% if (reactive) { %>Reactive<% } %>CassandraRepository<<%= persistClass %>, <%= primaryKey.type %>> {} |
56 changes: 56 additions & 0 deletions
56
...ngodb/src/main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository.kt.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<%# | ||
Copyright 2013-2024 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
Licensed under the Apache License, Version 2.0 (the " | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-%> | ||
package <%= entityAbsolutePackage %>.repository | ||
import <%= entityAbsolutePackage %>.domain.<%= persistClass %> | ||
<%_ if (implementsEagerLoadApis) { _%> | ||
import org.springframework.data.domain.Page | ||
import org.springframework.data.domain.Pageable | ||
<%_ } _%> | ||
import org.springframework.data.mongodb.repository.Query | ||
import org.springframework.data.mongodb.repository.MongoRepository | ||
import org.springframework.stereotype.Repository | ||
<%_ if (implementsEagerLoadApis) { _%> | ||
import java.util.Optional | ||
<%_ } _%> | ||
<%_ if (primaryKey.typeUUID) { _%> | ||
import java.util.UUID | ||
<%_ } _%> | ||
/** | ||
* <%= springDataDescription %> repository for the <%= persistClass %> entity. | ||
*/ | ||
<%_ if (!implementsEagerLoadApis) { _%> | ||
@Suppress("unused") | ||
<%_ } _%> | ||
@Repository | ||
interface <%=entityClass%>Repository : MongoRepository<<%=persistClass%>, <%= primaryKey.type %>> { | ||
<%_ if (implementsEagerLoadApis) { _%> | ||
@Query("{}") | ||
fun findAllWithEagerRelationships(pageable: Pageable): Page<<%= persistClass %>> | ||
@Query("{}") | ||
fun findAllWithEagerRelationships(): MutableList<<%= persistClass %>> | ||
@Query("{'id': ?0}") | ||
fun findOneWithEagerRelationships(id: <%= primaryKey.type %>): Optional<<%= persistClass %>> | ||
<%_ } _%> | ||
} |
62 changes: 62 additions & 0 deletions
62
.../main/kotlin/_package_/_entityPackage_/repository/_entityClass_Repository_reactive.kt.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<%# | ||
Copyright 2013-2024 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
Licensed under the Apache License, Version 2.0 (the " | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-%> | ||
package <%= entityAbsolutePackage %>.repository | ||
import <%= entityAbsolutePackage %>.domain.<%= persistClass %> | ||
<%_ if (!paginationNo || implementsEagerLoadApis) { _%> | ||
import org.springframework.data.domain.Pageable | ||
<%_ } _%> | ||
<%_ if (implementsEagerLoadApis) { _%> | ||
import org.springframework.data.mongodb.repository.Query | ||
<%_ } _%> | ||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository | ||
import org.springframework.stereotype.Repository | ||
<%_ if (!paginationNo || implementsEagerLoadApis) { _%> | ||
import reactor.core.publisher.Flux | ||
<%_ } _%> | ||
<%_ if (implementsEagerLoadApis) { _%> | ||
import reactor.core.publisher.Mono | ||
<%_ } _%> | ||
<%_ if (primaryKey.typeUUID) { _%> | ||
import java.util.UUID | ||
<%_ } _%> | ||
/** | ||
* <%= springDataDescription %> repository for the <%= persistClass %> entity. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Repository | ||
interface <%= entityClass %>Repository: ReactiveMongoRepository<<%= persistClass %>, <%= primaryKey.type %>> { | ||
<%_ if (!paginationNo) { _%> | ||
fun findAllBy(pageable: Pageable?): Flux<<%= persistClass %>> | ||
<%_ } _%> | ||
<%_ if (implementsEagerLoadApis) { _%> | ||
@Query("{}") | ||
fun findAllWithEagerRelationships(pageable: Pageable): Flux<<%= persistClass %>> | ||
@Query("{}") | ||
fun findAllWithEagerRelationships(): Flux<<%= persistClass %>> | ||
@Query("{'id': ?0}") | ||
fun findOneWithEagerRelationships(id: <%= primaryKey.type %>): Mono<<%= persistClass %>> | ||
<%_ } _%> | ||
} |
Oops, something went wrong.