-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from codeconsole/6.0.x-restore-scripts
Restore shell scripts
- Loading branch information
Showing
6 changed files
with
197 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
description("Creates a scaffolded controller") { | ||
usage 'create-controller [controller name]' | ||
completer org.grails.cli.interactive.completers.DomainClassCompleter | ||
argument name:'Controller Name', description:"The name of controller", required:true | ||
flag name:'force', description:"Whether to overwrite existing files" | ||
} | ||
|
||
def model = model(args[0]) | ||
def overwrite = flag('force') ? true : false | ||
|
||
render template: template('scaffolding/ScaffoldedController.groovy'), | ||
destination: file("grails-app/controllers/${model.packagePath}/${model.convention("Controller")}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
return true |
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,15 @@ | ||
import org.grails.cli.interactive.completers.DomainClassCompleter | ||
|
||
description("Generates a controller that performs CRUD operations and the associated views") { | ||
usage "grails generate-all [DOMAIN CLASS]" | ||
argument name: 'Domain Class', description: "The name of the domain class", required: true | ||
completer DomainClassCompleter | ||
flag name: 'force', description: "Whether to overwrite existing files" | ||
} | ||
|
||
if (args) { | ||
generateController(*args) | ||
generateViews(*args) | ||
} else { | ||
error "No domain class specified" | ||
} |
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,41 @@ | ||
import org.grails.cli.interactive.completers.DomainClassCompleter | ||
|
||
description( "Generates an asynchronous controller that performs CRUD operations" ) { | ||
usage "grails generate-async-controller [DOMAIN CLASS]" | ||
completer DomainClassCompleter | ||
flag name:'force', description:"Whether to overwrite existing files" | ||
} | ||
|
||
|
||
if(args) { | ||
def classNames = args | ||
if(args[0] == '*') { | ||
classNames = resources("file:grails-app/domain/**/*.groovy") | ||
.collect { className(it) } | ||
} | ||
for(arg in classNames) { | ||
def sourceClass = source(arg) | ||
def overwrite = flag('force') ? true : false | ||
if(sourceClass) { | ||
def model = model(sourceClass) | ||
render template: template('scaffolding/AsyncController.groovy'), | ||
destination: file("grails-app/controllers/${model.packagePath}/${model.convention('Controller')}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
render template: template('scaffolding/AsyncSpec.groovy'), | ||
destination: file("src/test/groovy/${model.packagePath}/${model.convention('ControllerSpec')}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
|
||
addStatus "Scaffolding completed for ${projectPath(sourceClass)}" | ||
} | ||
else { | ||
error "Domain class not found for name $arg" | ||
} | ||
} | ||
} | ||
else { | ||
error "No domain class specified" | ||
} |
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,51 @@ | ||
import org.grails.cli.interactive.completers.DomainClassCompleter | ||
|
||
description( "Generates a controller that performs CRUD operations" ) { | ||
usage "grails generate-controller [DOMAIN CLASS]" | ||
completer DomainClassCompleter | ||
flag name:'force', description:"Whether to overwrite existing files" | ||
} | ||
|
||
|
||
if(args) { | ||
def classNames = args | ||
if(args[0] == '*') { | ||
classNames = resources("file:grails-app/domain/**/*.groovy") | ||
.collect { className(it) } | ||
} | ||
for(arg in classNames) { | ||
def sourceClass = source(arg) | ||
def overwrite = flag('force') ? true : false | ||
if(sourceClass) { | ||
def model = model(sourceClass) | ||
render template: template('scaffolding/Controller.groovy'), | ||
destination: file("grails-app/controllers/${model.packagePath}/${model.convention('Controller')}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
render template: template('scaffolding/Service.groovy'), | ||
destination: file("grails-app/services/${model.packagePath}/${model.convention('Service')}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
render template: template('scaffolding/Spec.groovy'), | ||
destination: file("src/test/groovy/${model.packagePath}/${model.convention('ControllerSpec')}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
render template: template('scaffolding/ServiceSpec.groovy'), | ||
destination: file("src/integration-test/groovy/${model.packagePath}/${model.convention('ServiceSpec')}.groovy"), | ||
model: model, | ||
overwrite: overwrite | ||
|
||
|
||
addStatus "Scaffolding completed for ${projectPath(sourceClass)}" | ||
} | ||
else { | ||
error "Domain class not found for name $arg" | ||
} | ||
} | ||
} | ||
else { | ||
error "No domain class specified" | ||
} |
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,45 @@ | ||
import org.grails.cli.interactive.completers.DomainClassCompleter | ||
|
||
description( "Generates GSP views for the specified domain class" ) { | ||
usage "grails generate-views [DOMAIN CLASS]|*" | ||
argument name:'Domain Class', description:"The name of the domain class, or '*' for all", required:true | ||
completer DomainClassCompleter | ||
flag name:'force', description:"Whether to overwrite existing files" | ||
} | ||
|
||
if(args) { | ||
def classNames = args | ||
if(args[0] == '*') { | ||
classNames = resources("file:grails-app/domain/**/*.groovy").collect { className(it) } | ||
} | ||
def viewNames = resources("file:src/main/templates/scaffolding/*.gsp") | ||
.collect { | ||
it.filename | ||
} | ||
if(!viewNames) { | ||
viewNames = resources("classpath*:META-INF/templates/scaffolding/*.gsp") | ||
.collect { | ||
it.filename | ||
} | ||
} | ||
|
||
for(arg in classNames) { | ||
def sourceClass = source(arg) | ||
def overwrite = flag('force') ? true : false | ||
if(sourceClass) { | ||
def model = model(sourceClass) | ||
viewNames.each { | ||
render template: template('scaffolding/'+it), | ||
destination: file("grails-app/views/${model.propertyName}/"+it), | ||
model: model, | ||
overwrite: overwrite | ||
} | ||
|
||
addStatus "Views generated for ${projectPath(sourceClass)}" | ||
} else { | ||
error "Domain class not found for name $arg" | ||
} | ||
} | ||
} else { | ||
error "No domain class specified" | ||
} |
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,29 @@ | ||
/* | ||
* Copyright 2012 Rob Fletcher | ||
* | ||
* 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 | ||
* | ||
* 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. | ||
*/ | ||
|
||
description "Installs scaffolding templates that use f:all to render properties", "grails install-templates" | ||
|
||
updateStatus "Copying scaffolding templates" | ||
mkdir "src/main/templates/scaffolding" | ||
copy { | ||
from templates("scaffolding/*.gsp") | ||
into "src/main/templates/scaffolding" | ||
} | ||
copy { | ||
from templates("scaffolding/*.groovy") | ||
into "src/main/templates/scaffolding" | ||
} | ||
addStatus "Template installation complete" |