Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This plugin uses [Gulp](http://gulpjs.com/) to build its resources.

1. Change to the project's root directory.
1. Install project dependencies with `npm install`.
1. Build the resources with `gulp release-all`.
1. Build the resources with `npm run release-all`.

## Gulp tasks
## NPM tasks

| Task | Description |
| --- | --- |
Expand Down
38 changes: 38 additions & 0 deletions LOCALDEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Local Deployment

This page is meant for people not willing to wait for an official plugin release.

### Build

```shell
npm run grails3:release

cd grails3/plugin

./gradlew clean
./gradlew build
```

### Public local

Steps to use new version locally:
* Add mavenLocal() as a repository location in the main build.gradle
* Make sure mavenLocal() is in the first position of the list.
* Make sure you are using the correct version of your library.

```
buildscript {
repositories {
mavenLocal()
...
```

Now, every time you change a line in the Library you need to execute within library project path, the following gradle command:

```shell
./gradlew build publishToMavenLocal
```

### Publish to S3

You can follow one of the guides on how to deploy to S3 bucket you can find in [Google](https://www.google.com/search?q=maven+publish+to+s3).
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ grails.project.dependency.resolution = {
Add a dependency in build.gradle

```groovy
runtime 'org.grails.plugins:grails-console:2.1.1'
runtime 'org.grails.plugins:grails-console:2.2.0'
```

## Usage
Expand Down Expand Up @@ -137,7 +137,12 @@ grails.plugin.springsecurity.controllerAnnotations.staticRules = [
* [Burt Beckwith](https://github.com/burtbeckwith)
* [Matt Sheehan](https://github.com/sheehan)
* [Mike Hugo](https://github.com/mjhugo)
* [Kamil Dybicz](https://github.com/kdybicz)

## Development

Please see [CONTRIBUTING.md](CONTRIBUTING.md)

## Local deployment

Please see [LOCALDEPLOYMENT.md](LOCALDEPLOYMENT.md)
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### v2.2.0
* Fix for Console hijacking `System.out` and breaking system logs
* Fix for `NullPointerException` when running empty script on server with `grails.databinding.convertEmptyStringsToNull` set to default value `true`
* Fix for `grails3/plugin` structure and code refactoring to match Grails v3.3+ recommendations
* Updated Handlebar Runtime to 4.7.6
* Updating most of Node project dev-dependencies
* Updating structure and format of `gulpfile.js` to match Gulp v4 recommendations
* Build with Java 8

### v2.1.1
* Fix #65 build with Java 7

Expand Down
3 changes: 2 additions & 1 deletion grails3/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.gradle
build
classes
classes
out
3 changes: 2 additions & 1 deletion grails3/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"
apply plugin:"org.grails.grails-gsp"

version "2.1.1"
version "2.2.0"
group "org.grails.plugins"

repositories {
Expand Down Expand Up @@ -57,6 +57,7 @@ dependencies {
provided "org.grails:grails-plugin-domain-class"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails:grails-web-testing-support"
testCompile 'net.bytebuddy:byte-buddy:1.14.0'
}

task repairPublicFiles(type: Copy) { // https://github.com/grails/grails-core/issues/629
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.grails.plugins.console

import grails.util.Environment


class EnabledInterceptor {

def consoleConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class ExecuteCommand {
String code
boolean autoImportDomains
}
package org.grails.plugins.console

import grails.validation.Validateable

class ExecuteCommand implements Validateable {
String code
boolean autoImportDomains

String getCode() {
return this.@code ?: ''
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import grails.core.GrailsApplication

class ConsoleService {

static transactional = false

GrailsApplication grailsApplication

/**
Expand All @@ -21,9 +19,6 @@ class ConsoleService {
ByteArrayOutputStream baos = new ByteArrayOutputStream()
PrintStream out = new PrintStream(baos)

PrintStream systemOut = System.out
System.out = out

Evaluation evaluation = new Evaluation()

Console console = new Console()
Expand All @@ -40,7 +35,6 @@ class ConsoleService {
}

evaluation.totalTime = System.currentTimeMillis() - startTime
System.out = systemOut

evaluation.console = console
evaluation.output = baos.toString('UTF8')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
package org.grails.plugins.console

import grails.converters.JSON
import grails.test.mixin.TestFor
import grails.testing.web.controllers.ControllerUnitTest
import org.apache.commons.io.FileUtils
import spock.lang.Specification

import java.nio.file.Files

@TestFor(ConsoleController)
class ConsoleControllerSpec extends Specification {
class ConsoleControllerSpec extends Specification implements ControllerUnitTest<ConsoleController> {

ConsoleService consoleService = Mock(ConsoleService)
ConsoleService consoleService
File tempDir

@Override
Closure doWithConfig() {{ config ->
config.grails.plugin.console.fileStore.remote.enabled = true
config.grails.plugin.console.csrfProtection.enabled = true
}}

void setup() {
JSON.createNamedConfig 'console', {}
ConsoleUtil.initJsonConfig()

consoleService = Mock(ConsoleService)
controller.consoleService = consoleService

tempDir = Files.createTempDirectory('console').toFile()
config.grails.plugin.console.fileStore.remote.enabled = true
config.grails.plugin.console.csrfProtection.enabled = true
controller.consoleConfig = new ConsoleConfig(config.grails.plugin.console)

controller.consoleConfig = new ConsoleConfig(config)
}

void cleanup() {
Expand Down Expand Up @@ -57,13 +65,14 @@ class ConsoleControllerSpec extends Specification {
String code = '"s"'

when:
controller.execute(new ExecuteCommand(code, false))
controller.execute(new ExecuteCommand(code: code, autoImportDomains: false))

then:
1 * consoleService.eval(code, false, request) >> new Evaluation(
result: 'test-result',
output: 'test-output',
totalTime: 10
totalTime: 10,
console: new Console()
)
with(response.json) {
result == "'test-result'"
Expand All @@ -77,17 +86,18 @@ class ConsoleControllerSpec extends Specification {
String code = ''

when:
controller.execute(new ExecuteCommand(code, false))
controller.execute(new ExecuteCommand(code: code, autoImportDomains: false))

then:
1 * consoleService.eval(code, false, request) >> new Evaluation(
result: 'test-result',
output: 'test-output',
totalTime: 10,
console: new Console(),
exception: new RuntimeException()
)
with(response.json) {
exception.stackTrace.contains 'RuntimeException'
exception.message.contains 'RuntimeException'
output == 'test-output'
totalTime != null
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package org.grails.plugins.console

import grails.test.mixin.TestFor
import grails.testing.services.ServiceUnitTest
import org.springframework.mock.web.MockHttpServletRequest
import spock.lang.Specification

@TestFor(ConsoleService)
class ConsoleServiceSpec extends Specification{

class ConsoleServiceSpec extends Specification implements ServiceUnitTest<ConsoleService> {

def request = new MockHttpServletRequest()

void 'service is not transactional'() {
expect:
!ConsoleService.transactional
}

void 'eval'() {
given:
String code = '''
Expand Down
89 changes: 34 additions & 55 deletions gulp-tasks/grails-builder.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,46 @@
'use strict';

const gulp = require('gulp');
const concat = require('gulp-concat');
const merge = require('merge-stream');
const mkdirp = require('mkdirp');
const through = require('through2');
const path = require('path');

const wrapPath = (relativeDir, fcn) => {
return through.obj(function(file, encoding, callback) {
let requirePath = path.relative(relativeDir, path.resolve(file.path));
let tag = fcn(requirePath);
file.contents = new Buffer(tag);
return callback(null, file);
})
};

class GrailsBuilder {
constructor(options) {
this.outputDir = options.outputDir;
this.relativeDir = options.relativeDir;
this.webDir = options.webDir;
this.faviconWrap = options.faviconWrap;
this.jsWrap = options.jsWrap;
this.cssWrap = options.cssWrap;
this.paths = options.paths;
import gulp from 'gulp';
import concat from 'gulp-concat';
import merge from 'merge-stream';
import mkdirp from 'mkdirp';

import wrapPath from './wrap-path.js'

export const build = (isDebug, options) => {
let appSrc, jsSrc, cssSrc;
if (isDebug) {
appSrc = './build/debug/**/*';
jsSrc = options.paths.vendor.js.concat(options.paths.app.js.debug).map(path => options.webDir + path);
cssSrc = options.paths.vendor.css.concat(options.paths.app.css.debug).map(path => options.webDir + path);
} else {
appSrc = './build/release/**/*';
jsSrc = options.paths.app.js.release.map(path => options.webDir + path);
cssSrc = options.paths.vendor.css.concat(options.paths.app.css.release).map(path => options.webDir + path);
}

build(isDebug) {
let appSrc, jsSrc, cssSrc;
if (isDebug) {
appSrc = './build/debug/**/*';
jsSrc = this.paths.vendor.js.concat(this.paths.app.js.debug).map(path => this.webDir + path);
cssSrc = this.paths.vendor.css.concat(this.paths.app.css.debug).map(path => this.webDir + path);
} else {
appSrc = './build/release/**/*';
jsSrc = this.paths.app.js.release.map(path => this.webDir + path);
cssSrc = this.paths.vendor.css.concat(this.paths.app.css.release).map(path => this.webDir + path);
}

merge([
gulp.src(appSrc),
gulp.src('./web/img/**/*', {base: './web/'}),
gulp.src('./web/vendor/**/*', {base: './web/'})
]).pipe(gulp.dest(this.webDir)).on('end', () => {
mkdirp(this.outputDir);

gulp.src([this.paths.favicon].map(path => this.webDir + path))
.pipe(wrapPath(this.relativeDir, this.faviconWrap))
return merge([
gulp.src(appSrc),
gulp.src('./web/img/**/*', { base: './web/' }),
gulp.src('./web/vendor/**/*', { base: './web/' }),
])
.pipe(gulp.dest(options.webDir))
.on('end', async () => {
await mkdirp(options.outputDir);

gulp.src([options.paths.favicon].map(path => options.webDir + path))
.pipe(wrapPath(options.relativeDir, options.faviconWrap))
.pipe(concat('_favicon.gsp'))
.pipe(gulp.dest(this.outputDir));
.pipe(gulp.dest(options.outputDir));

gulp.src(jsSrc)
.pipe(wrapPath(this.relativeDir, this.jsWrap))
.pipe(wrapPath(options.relativeDir, options.jsWrap))
.pipe(concat('_js.gsp'))
.pipe(gulp.dest(this.outputDir));
.pipe(gulp.dest(options.outputDir));

gulp.src(cssSrc)
.pipe(wrapPath(this.relativeDir, this.cssWrap))
.pipe(wrapPath(options.relativeDir, options.cssWrap))
.pipe(concat('_css.gsp'))
.pipe(gulp.dest(this.outputDir));
.pipe(gulp.dest(options.outputDir));
});
}
}

module.exports = GrailsBuilder;
};
Loading