From 67c2a02604570cacc7c3d975d1f3a5232036a6c0 Mon Sep 17 00:00:00 2001 From: Zachary Klein Date: Mon, 17 Jun 2019 22:24:29 -0400 Subject: [PATCH] Added create-service command - https://github.com/grails/grails-core/issues/11342 --- commands/create-service.yml | 17 +++++++++++++++++ templates/artifacts/Service.groovy | 10 ++++++++++ templates/testing/Service.groovy | 17 +++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 commands/create-service.yml create mode 100644 templates/artifacts/Service.groovy create mode 100644 templates/testing/Service.groovy diff --git a/commands/create-service.yml b/commands/create-service.yml new file mode 100644 index 0000000..3e3b37e --- /dev/null +++ b/commands/create-service.yml @@ -0,0 +1,17 @@ +description: + - Creates a Service + - usage: 'create-service [service name]' + - completer: org.grails.cli.interactive.completers.DomainClassCompleter + - argument: "Service Name" + description: "The name of the service" + - flag: force + description: Whether to override existing files +steps: + - command: render + template: templates/artifacts/Service.groovy + destination: grails-app/services/@artifact.package.path@/@artifact.name@Service.groovy + convention: Service + - command: render + template: templates/testing/Service.groovy + destination: src/test/groovy/@artifact.package.path@/@artifact.name@ServiceSpec.groovy + convention: Service diff --git a/templates/artifacts/Service.groovy b/templates/artifacts/Service.groovy new file mode 100644 index 0000000..43faf6d --- /dev/null +++ b/templates/artifacts/Service.groovy @@ -0,0 +1,10 @@ +@artifact.package@ +import grails.gorm.transactions.Transactional + +@Transactional +class @artifact.name@Service { + + def serviceMethod() { + + } +} diff --git a/templates/testing/Service.groovy b/templates/testing/Service.groovy new file mode 100644 index 0000000..d43b507 --- /dev/null +++ b/templates/testing/Service.groovy @@ -0,0 +1,17 @@ +@artifact.package@ +import grails.testing.services.ServiceUnitTest +import spock.lang.Specification + +class @artifact.name@ServiceSpec extends Specification implements ServiceUnitTest<@artifact.name@Service>{ + + def setup() { + } + + def cleanup() { + } + + void "test something"() { + expect:"fix me" + true == false + } +}