Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Oct 3, 2018
2 parents 5918e2d + c055066 commit f652fff
Show file tree
Hide file tree
Showing 101 changed files with 1,966 additions and 765 deletions.
2 changes: 1 addition & 1 deletion build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java.debug=true

#dependencies
dependencies.dir=${basedir}/lib
cfml.version=5.2.8.50
cfml.version=5.2.9.31
cfml.loader.version=2.1.14
cfml.cli.version=${cfml.loader.version}.${cfml.version}
lucee.version=${cfml.version}
Expand Down
48 changes: 24 additions & 24 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.2.0"/>
<property name="commandbox.stableVersion" value="4.2.0"/>
<property name="commandbox.version" value="4.3.0"/>
<property name="commandbox.stableVersion" value="4.3.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down Expand Up @@ -327,8 +327,8 @@ External Dependencies:
</fileset>
</copy>

<!--
<!- - process each lex extension - ->

<!-- process each lex extension -->
<sequential>
<for param="file">
<path>
Expand All @@ -346,36 +346,36 @@ External Dependencies:
<fileset dir="${temp.dir}/luceejarBundles" includes="**/*" defaultexcludes="no"/>
</delete>

<!- - unzip the extension - ->
<!-- unzip the extension -->
<unzip dest="${temp.dir}/luceejarExtension/" src="@{file}" overwrite="true" />


<!- - Test if a directory called "my_directory" is present - ->
<!-- Test if a directory called "my_directory" is present -->
<if>
<available file="${temp.dir}/luceejarExtension/jars" type="dir" />
<then>
<echo message="Jars Directory exists" />

<!- - delete the old extension - ->
<!-- delete the old extension -->
<delete file="@{file}"/>

<!- - pack the OSGI bundles - ->
<!-- pack the OSGI bundles -->
<packjars dir="${temp.dir}/luceejarExtension/jars" packdir="${temp.dir}/luceejarBundles" excludes="ESAPI*,microsoft-*"/>

<!- - delete the unpacked bundles - ->
<!-- delete the unpacked bundles -->
<delete>
<fileset dir="${temp.dir}/luceejarExtension/jars" includes="*.jar"/>
</delete>

<!- - copy packed bundles over to jar folder - ->
<!-- copy packed bundles over to jar folder -->
<copy todir="${temp.dir}/luceejarExtension/jars">
<fileset dir="${temp.dir}/luceejarBundles">
<include name="*"/>
</fileset>
</copy>


<!- - Zip the extension back up - ->
<!-- Zip the extension back up -->
<zip destfile="@{file}">
<fileset dir="${temp.dir}/luceejarExtension"/>
</zip>
Expand All @@ -386,36 +386,36 @@ External Dependencies:
</sequential>
</for>
</sequential>
-->


<!--

<echo message="Compressing core.lco"/>

<delete includeEmptyDirs="true">
<fileset dir="${temp.dir}/luceejarBundles" includes="**/*" defaultexcludes="no"/>
</delete>-->
</delete>

<!-- Temporarily rename lco file to jar file so packjars will pick it up
<!-- Temporarily rename lco file to jar file so packjars will pick it up -->
<move file="${temp.dir}/luceejar/core/core.lco" tofile="${temp.dir}/luceejar/core/core.jar"/>
-->
<!-- pack core.lco

<!-- pack core.lco -->
<packjars dir="${temp.dir}/luceejar/core" packdir="${temp.dir}/luceejarBundles" excludes="dummy"/>
-->
<!-- delete the unpacked bundles

<!-- delete the unpacked bundles -->
<delete>
<fileset dir="${temp.dir}/luceejar/core" includes="*.jar"/>
</delete> -->
</delete>

<!-- copy packed bundles over to jar folder
<!-- copy packed bundles over to jar folder -->
<copy todir="${temp.dir}/luceejar/core">
<fileset dir="${temp.dir}/luceejarBundles">
<include name="*"/>
</fileset>
</copy> -->
</copy>

<!-- put file name back
<!-- put file name back -->
<move file="${temp.dir}/luceejar/core/core.jar.pack.gz" tofile="${temp.dir}/luceejar/core/core.lco.pack.gz"/>
-->

<!-- Zip lucee jar back up -->
<zip destfile="${lucee.lib.dir}/lucee-${cfml.version}-packed.jar">
<fileset dir="${temp.dir}/luceejar"/>
Expand Down
44 changes: 41 additions & 3 deletions src/cfml/system/BaseCommand.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ component accessors="true" singleton {

// This method needs to be overridden by the concrete class.
function run() {
return 'This command CFC has not implemented a run() method.';
error( 'This command CFC has not implemented a run() method.' );
}

function getPrinter() {
return variables.print;
}

// Convenience method for getting stuff from WireBox
Expand Down Expand Up @@ -123,7 +127,14 @@ component accessors="true" singleton {
* @command.hint The command to run. Pass the same string a user would type at the shell.
**/
function runCommand( required command, returnOutput=false ) {
return shell.callCommand( arguments.command, arguments.returnOutput );
var results = shell.callCommand( arguments.command, arguments.returnOutput );

// If the previous command chain failed
if( shell.getExitCode() != 0 ) {
error( 'Command returned failing exit code (#shell.getExitCode()#)', 'Failing Command: ' & command, shell.getExitCode(), errorCode=shell.getExitCode() );
}

return results;
}

/**
Expand All @@ -141,6 +152,19 @@ component accessors="true" singleton {
return getinstance( 'watcher' );
}

/**
* This resolves an absolute or relative path using the rules of the operating system and CLI.
* It doesn't follow CF mappings and will also always return a trailing slash if pointing to
* an existing directory.
*
* Resolve the incoming path from the file system
* @path.hint The directory to resolve
* @basePath.hint An expanded base path to resolve the path against. Defaults to CWD.
*/
function resolvePath( required string path, basePath=shell.pwd() ) {
return filesystemUtil.resolvepath( path, basePath );
}

/**
* Return a new globber
**/
Expand All @@ -157,8 +181,22 @@ component accessors="true" singleton {
**/
function propertyFile( propertyFilePath='' ) {
var propertyFile = wirebox.getInstance( 'propertyFile@propertyFile' );

// If the user passed a propertyFile path
if( propertyFilePath.len() ) {
propertyFile.load( propertyFilePath );

// Make relative paths resolve to the current folder that the task lives in.
propertyFilePath = resolvePath( propertyFilePath );

// If it exists, go ahead and load it now
if( fileExists( propertyFilePath ) ){
propertyFile.load( propertyFilePath );
} else {
// Otherwise, just set it so it can be used later on save.
propertyFile
.setPath( propertyFilePath );
}

}
return propertyFile;
}
Expand Down
50 changes: 16 additions & 34 deletions src/cfml/system/BaseTask.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,13 @@ component accessors="true" extends='commandbox.system.BaseCommand' {

// Tasks mostly just do everything commands do


/**
* Return a new PropertyFile instance
**/
function propertyFile( propertyFilePath='' ) {
var propertyFile = wirebox.getInstance( 'propertyFile@propertyFile' );

// If the user passed a propertyFile path
if( propertyFilePath.len() ) {

// Make relative paths resolve to the current folder that the task lives in.
propertyFilePath = fileSystemUtil.resolvePath(
propertyFilePath,
getDirectoryFromPath( getCurrentTemplatePath() )
);

// If it exists, go ahead and load it now
if( fileExists( propertyFilePath ) ){
propertyFile.load( propertyFilePath );
} else {
// Otherwise, just set it so it can be used later on save.
propertyFile
.setPath( propertyFilePath );
}

}
return propertyFile;
}

/**
* Run another task by DSL.
* @taskFile The name of the task to run.
**/
function task( required taskFile='task' ) {
return getinstance( name='TaskDSL', initArguments={ taskFile : arguments.taskFile } );
return getinstance( name='TaskDSL', initArguments={ taskFile : arguments.taskFile } )
.inWorkingDirectory( getDirectoryFromPath( getCurrentTemplatePath() ) );
}

/**
Expand All @@ -60,10 +32,7 @@ component accessors="true" extends='commandbox.system.BaseCommand' {
function loadModule( required string moduleDirectory ) {

// Expand path relative to the task CFC.
moduleDirectory = fileSystemUtil.resolvePath(
moduleDirectory,
getDirectoryFromPath( getCurrentTemplatePath() )
);
moduleDirectory = resolvePath( moduleDirectory );

// A little validation...
if( !directoryExists( moduleDirectory ) ) {
Expand All @@ -84,5 +53,18 @@ component accessors="true" extends='commandbox.system.BaseCommand' {
// Load it up!!
wirebox.getInstance( 'moduleService' ).registerAndActivateModule( moduleName, invocationPath );
}

/**
* This resolves an absolute or relative path using the rules of the operating system and CLI.
* It doesn't follow CF mappings and will also always return a trailing slash if pointing to
* an existing directory.
*
* Resolve the incoming path from the file system
* @path.hint The directory to resolve
* @basePath.hint An expanded base path to resolve the path against. Defaults to direcory that the task lives in.
*/
function resolvePath( required string path, basePath=getDirectoryFromPath( getCurrentTemplatePath() ) ) {
return filesystemUtil.resolvepath( path, basePath );
}

}
2 changes: 1 addition & 1 deletion src/cfml/system/Bootstrap.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ This file will stay running the entire time the shell is open
bufferedReader = createObject( 'java', 'java.io.BufferedReader' ).init( inputStreamReader );
// Verify if we can run CommandBox Java v. 1.7+
if( !findNoCase( "1.8", server.java.version ) ){
if( !findNoCase( "1.8", server.java.version ) && 0 ){
// JLine isn't loaded yet, so I have to use systemOutput() here.
systemOutput( "The Java Version you have (#server.java.version#) is not supported by CommandBox. Please install a Java JRE/JDK 1.8." );
sleep( 5000 );
Expand Down
26 changes: 21 additions & 5 deletions src/cfml/system/Shell.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,17 @@ component accessors="true" singleton {
}

variables.keepRunning = false;
continue;
continue;

// Catch all for custom user interrupt thrown from CFML
} catch( any var e ) {

if( e.type == 'UserInterruptException' ) {
continue;
} else {
rethrow;
}

}

// If the standard input isn't avilable, bail. This happens
Expand Down Expand Up @@ -720,6 +730,7 @@ component accessors="true" singleton {
boolean initialCommand=false ) {

var job = wirebox.getInstance( 'interactiveJob' );
var progressBarGeneric = wirebox.getInstance( 'progressBarGeneric' );

// Commands a loaded async in interactive mode, so this is a failsafe to ensure the CommandService
// is finished. Especially useful for commands run onCLIStart. Wait up to 5 seconds.
Expand Down Expand Up @@ -751,6 +762,7 @@ component accessors="true" singleton {
rethrow;
} else {

progressBarGeneric.clear();
if( job.isActive() ) {
job.errorRemaining();
}
Expand All @@ -763,6 +775,8 @@ component accessors="true" singleton {
if( !initialCommand ) {
rethrow;
} else {

progressBarGeneric.clear();
if( job.isActive() ) {
job.errorRemaining();
}
Expand All @@ -777,8 +791,9 @@ component accessors="true" singleton {
if( !initialCommand ) {
rethrow;
// This type of error means the user hit Ctrl-C, when not in a readLine() call (and hit my custom signal handler). Duck out and move along.
} else if( e.getPageException().getRootCause().getClass().getName() == 'java.lang.InterruptedException' ) {

} else if( e.getPageException().getRootCause().getClass().getName() == 'java.lang.InterruptedException' || e.type == 'UserInterruptException' || e.message == 'UserInterruptException' ) {

progressBarGeneric.clear();
if( job.isActive() ) {
job.errorRemaining();
}
Expand All @@ -788,7 +803,8 @@ component accessors="true" singleton {
variables.reader.getTerminal().writer().print( variables.print.boldRedLine( 'CANCELLED' ) );
// Anything else is completely unexpected and means boom booms happened-- full stack please.
} else {


progressBarGeneric.clear();
if( job.isActive() ) {
job.errorRemaining( e.message );
variables.reader.getTerminal().writer().println();
Expand All @@ -814,7 +830,7 @@ component accessors="true" singleton {
if( isArray( result ) ){
return variables.reader.getTerminal().writer().printColumns( result );
}
result = variables.formatterUtil.formatJson( serializeJSON( result ) );
result = variables.formatterUtil.formatJson( result );
printString( result );
} else if( !isNull( result ) && len( result ) ) {
// If there is an active job, print our output through it
Expand Down
3 changes: 1 addition & 2 deletions src/cfml/system/config/LogBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ component {
fileMaxArchives = 5,
filename = "commandbox",
filepath = expandpath( '/commandbox-home' ) & "/logs",
autoExpand=false,
async=true
autoExpand=false
}
},
ANSIConsoleAppender = {
Expand Down
3 changes: 2 additions & 1 deletion src/cfml/system/config/box.json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"testSpecs":"",
"verbose":true,
"watchDelay":500,
"watchPaths":"**.cfc"
"watchPaths":"**.cfc",
"options":{}
}
}
Loading

0 comments on commit f652fff

Please sign in to comment.