Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Mar 1, 2019
2 parents 61b388d + c74d4b9 commit c9dd2f1
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 113 deletions.
4 changes: 2 additions & 2 deletions build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ java.debug=true
#dependencies
dependencies.dir=${basedir}/lib
cfml.version=5.2.9.31
cfml.loader.version=2.2.9
cfml.loader.version=2.2.11
cfml.cli.version=${cfml.loader.version}.${cfml.version}
lucee.version=${cfml.version}
lucee.config.version=5.2.4.37
jre.adoptVesionr=openjdk8
jre.version=jdk8u192-b12
jre.version=jdk8u202-b08
launch4j.version=3.12
runwar.version=3.8.1-SNAPSHOT
jline.version=3.8.2
Expand Down
12 changes: 10 additions & 2 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ External Dependencies:
<property name="distro.groupID" value="ortussolutions" />
<property name="distro.name" value="commandbox"/>
<!-- Special things happen when the version and stableVersion are the same value as that signifies a "stable" build. -->
<property name="commandbox.version" value="4.5.0"/>
<property name="commandbox.stableVersion" value="4.5.0"/>
<property name="commandbox.version" value="4.6.0"/>
<property name="commandbox.stableVersion" value="4.6.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down Expand Up @@ -199,6 +199,14 @@ External Dependencies:
<lucee-error-template path="/lucee/templates/error/error-cli.cfm"
configfile="${temp.dir}/engine/cfml/cli/cfml-web/lucee-web.xml.cfm" />

<!-- Turn of the default time server setting in Lucee -->
<replaceregexp
file="${temp.dir}/engine/cfml/cli/lucee-server/context/lucee-server.xml"
match='&lt;regional.*/&gt;'
replace="&lt;regional timeserver=&quot;pool.ntp.org&quot; use-timeserver=&quot;false&quot; /&gt;"
flags="i"
encoding="UTF-8" />

<!-- Copy Resources to build cli bin -->
<copy todir="${temp.dir}/cli/bin/resource" encoding="UTF-8">
<fileset dir="${src.dir}/resources"/>
Expand Down
5 changes: 3 additions & 2 deletions src/cfml/system/BaseCommand.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ component accessors="true" singleton {
variables.configService = wirebox.getInstance( "ConfigService" );
variables.SystemSettings = wirebox.getInstance( "SystemSettings" );
variables.job = wirebox.getInstance( "interactiveJob" );
variables.thisThread = createObject( 'java', 'java.lang.Thread' ).currentThread();

variables.exitCode = 0;
return this;
Expand Down Expand Up @@ -294,8 +295,8 @@ component accessors="true" singleton {
* if the user has hit Ctrl-C. This method will throw an UserInterruptException
* which you should not catch. It will unroll the stack all the way back to the shell
*/
function checkInterrupted() {
shell.checkInterrupted();
function checkInterrupted( thisThread=variables.thisThread ) {
shell.checkInterrupted( argumentCollection=arguments );
}


Expand Down
6 changes: 4 additions & 2 deletions src/cfml/system/Shell.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,10 @@ component accessors="true" singleton {
* if the user has hit Ctrl-C. This method will throw an UserInterruptException
* which you should not catch. It will unroll the stack all the way back to the shell
*/
function checkInterrupted() {
var thisThread = createObject( 'java', 'java.lang.Thread' ).currentThread();
function checkInterrupted( thisThread ) {
if( isNull( arguments.thisThread ) ) {
thisThread = createObject( 'java', 'java.lang.Thread' ).currentThread();
}

// Has the user tried to interrupt this thread?
if( thisThread.isInterrupted() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/cfml/system/endpoints/ForgeBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ component accessors="true" implements="IEndpointInteractive" {
try {
forgebox.getStorageLocation( props.slug, props.version, props.APIToken );
if ( ! arguments.force ) {
consoleLogger.warn( "A zip for this version has already been uploaded. If you want to override the uploaded zip, run this command with the `force` flag. We will continue to update your package metadata." );
consoleLogger.error( "A zip for this version has already been uploaded. If you want to override the uploaded zip, run this command with the `force` flag. We will continue to update your package metadata." );
upload = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cfml/system/modules/propertyFile/ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ component {
function configure(){
}

}
}
4 changes: 2 additions & 2 deletions src/cfml/system/modules/propertyFile/box.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name":"PropertyFile Util",
"version":"1.1.0",
"version":"1.2.0",
"author":"Brad Wood",
"location":"bdw429s/PropertyFile#v1.1.0",
"location":"bdw429s/PropertyFile#v1.2.0",
"homepage":"https://github.com/bdw429s/PropertyFile/",
"documentation":"https://github.com/bdw429s/PropertyFile/blob/master/readme.md",
"repository":{
Expand Down
47 changes: 24 additions & 23 deletions src/cfml/system/modules/propertyFile/models/PropertyFile.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
* I am a new Model Object
*/
component accessors="true"{

// Properties
property name='javaPropertyFile';
// A fully qualified path to a property file
property name='path';
property name='syncedNames';


/**
* Constructor
Expand All @@ -17,46 +18,46 @@ component accessors="true"{
setJavaPropertyFile( createObject( 'java', 'java.util.Properties' ).init() );
return this;
}

/**
* load
* @load A fully qualified path to a property file
*/
function load( required string path){
setPath( arguments.path );
var fis = CreateObject( 'java', 'java.io.FileInputStream' ).init( expandPath( path ) );
var fis = CreateObject( 'java', 'java.io.FileInputStream' ).init( path );
var BOMfis = CreateObject( 'java', 'org.apache.commons.io.input.BOMInputStream' ).init( fis );
var propertyFile = getJavaPropertyFile();
propertyFile.load( BOMfis );
BOMfis.close();


var props = propertyFile.propertyNames();
var syncedNames = getSyncedNames();
while( props.hasMoreElements() ) {
var prop = props.nextElement();
this[ prop ] = get( prop );
syncedNames.append( prop );
syncedNames.append( prop );
}
setSyncedNames( syncedNames );

return this;
}

/**
* store
* @load A fully qualified path to a property file. File will be created if it doesn't exist.
*/
function store( string path=variables.path ){
syncProperties();

if( !fileExists( arguments.path ) ) {
directoryCreate( getDirectoryFromPath( arguments.path ), true, true );
fileWrite( arguments.path, '' );
}

var fos = CreateObject( 'java', 'java.io.FileOutputStream' ).init( expandPath( arguments.path ) );
var fos = CreateObject( 'java', 'java.io.FileOutputStream' ).init( arguments.path );
getJavaPropertyFile().store( fos, '' );
fos.close();

return this;
}

Expand All @@ -65,7 +66,7 @@ component accessors="true"{
*/
function get( required string name, string defaultValue ){
if( structKeyExists( arguments, 'defaultValue' ) ) {
return getJavaPropertyFile().getProperty( name, defaultValue );
return getJavaPropertyFile().getProperty( name, defaultValue );
} else if( exists( name ) ) {
return getJavaPropertyFile().getProperty( name );
} else {
Expand All @@ -78,14 +79,14 @@ component accessors="true"{
*/
function set( required string name, required string value ){
getJavaPropertyFile().setProperty( name, value );

var syncedNames = getSyncedNames();
this[ name ] = value;
if( !arrayContains( syncedNames, name ) ){
syncedNames.append( name );
}
setSyncedNames( syncedNames );

return this;
}

Expand All @@ -95,7 +96,7 @@ component accessors="true"{
function remove( required string name ){
if( exists( name ) ) {
getJavaPropertyFile().remove( name );

var syncedNames = getSyncedNames();
if( arrayFind( syncedNames, name ) ){
syncedNames.deleteAt( arrayFind( syncedNames, name ) );
Expand All @@ -122,23 +123,23 @@ component accessors="true"{
structAppend( result, getJavaPropertyFile() );
return result;
}

/**
* Keeps public properties in sync with Java object
*/
private function syncProperties() {
var syncedNames = getSyncedNames();
var ignore = listToArray( 'init,load,store,get,set,exists,remove,exists,getAsStruct,$mixed' );
var propertyFile = getJavaPropertyFile();

// This CFC's public properties
for( var prop in this ) {
// Set any new/updated properties in, excluding actual methods and non-simple values
if( !ignore.findNoCase( prop ) && isSimpleValue( this[ prop ] ) ) {
set( prop, this[ prop ] );
}
}

// All the properties in the Java object
var props = propertyFile.propertyNames();
while( props.hasMoreElements() ) {
Expand All @@ -148,7 +149,7 @@ component accessors="true"{
remove( prop );
}
}

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ component aliases='coldbox create controller' {

// Are we creating views?
if( arguments.views ) {
var viewPath = arguments.viewsDirectory & '/' & arguments.name & '/' & thisAction & '.cfm';

var camelCaseHandlerName = arguments.name.left( 1 ).lCase();
if( arguments.name.len() > 1 ) {
camelCaseHandlerName &= arguments.name.right( -1 );
}

var viewPath = resolvePath( arguments.viewsDirectory & '/' & camelCaseHandlerName & '/' & thisAction & '.cfm' );
// Create dir if it doesn't exist
directorycreate( getDirectoryFromPath( viewPath ), true, true );
// Create View Stub
fileWrite( viewPath, '<cfoutput>#cr#<h1>#arguments.name#.#thisAction#</h1>#cr#</cfoutput>' );
print.greenLine( 'Created ' & arguments.viewsDirectory & '/' & arguments.name & '/' & thisAction & '.cfm' );
print.greenLine( 'Created ' & viewPath );
}

// Are we creating tests cases on actions
Expand All @@ -109,7 +115,7 @@ component aliases='coldbox create controller' {
handlerTestContent = replaceNoCase( handlerTestContent, '|TestCases|', '', 'all' );
}

var handlerPath = '#arguments.directory#/#arguments.name#.cfc';
var handlerPath = resolvePath( '#arguments.directory#/#arguments.name#.cfc' );
// Create dir if it doesn't exist
directorycreate( getDirectoryFromPath( handlerPath ), true, true );

Expand All @@ -124,7 +130,7 @@ component aliases='coldbox create controller' {
print.greenLine( 'Created #handlerPath#' );

if( arguments.integrationTests ) {
var testPath = '#arguments.testsDirectory#/#arguments.name#Test.cfc';
var testPath = resolvePath( '#arguments.testsDirectory#/#arguments.name#Test.cfc' );
// Create dir if it doesn't exist
directorycreate( getDirectoryFromPath( testPath ), true, true );
// Create the tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ component aliases="init" {

// Ignore List
if( arguments.ignoreList ){
arguments[ "ignore" ] = serializeJSON( [ '**/.*', 'test', 'tests' ] );
arguments[ "ignore" ] = serializeJSON( [ '**/.*', '/test/', '/tests/' ] );
}
// Cleanup the argument so it does not get written.
structDelete( arguments, "ignoreList" );
Expand Down
3 changes: 3 additions & 0 deletions src/cfml/system/modules_app/system-commands/commands/repl.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ component {
break;
}
}

// Evaluate any ${} placeholders
command = systemSettings.expandSystemSettings( command )

// add command to our parser
REPLParser.addCommandLine( command );
Expand Down
10 changes: 9 additions & 1 deletion src/cfml/system/modules_app/system-commands/commands/run.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ component{
commandArray = [ nativeShell, '-i', '-c', arguments.command & ' 2>&1 && ( exit $? > /dev/null )' ];
}

if( configService.getSetting( 'debugNativeExecution', false ) ) {
print.line( commandArray.tolist( ' ' ) ).toConsole();
}

var exitCode = 1;
// grab the current working directory
var CWDFile = createObject( 'java', 'java.io.File' ).init( resolvePath( '' ) );
Expand Down Expand Up @@ -111,9 +115,13 @@ component{
// I convert the byte array in the piped input stream to a character array
var inputStreamReader = createObject( 'java', 'java.io.InputStreamReader' ).init( inputStream );

var interruptCount = 0;
// This will block/loop until the input stream closes, which means this loops until the process ends.
while( ( var char = inputStreamReader.read() ) != -1 ) {
checkInterrupted();
if( ++interruptCount > 1000 ) {
checkInterrupted();
interruptCount=0;
}
// if running non-interactive, gather the output of the command
processOutputStringBuilder.append( javaCast( 'char', char ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ component singleton accessors=true {
try {

// Run the task
taskCFC[ target ]( argumentCollection = taskArgs );
local.returnedExitCode = taskCFC[ target ]( argumentCollection = taskArgs );
} catch( any e ) {

// If this task didn't already set a failing exit code...
Expand All @@ -100,7 +100,11 @@ component singleton accessors=true {

} finally {
// Set task exit code into the shell
shell.setExitCode( taskCFC.getExitCode() );
if( !isNull( local.returnedExitCode ) && isSimpleValue( local.returnedExitCode ) ) {
shell.setExitCode( val( local.returnedExitCode ) );
} else {
shell.setExitCode( taskCFC.getExitCode() );
}
}

// If the previous Task failed
Expand Down
Loading

0 comments on commit c9dd2f1

Please sign in to comment.