Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed May 20, 2022
2 parents ba7c150 + e749459 commit 589e058
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 53 deletions.
6 changes: 3 additions & 3 deletions build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ java.debug=true

#dependencies
dependencies.dir=${basedir}/lib
cfml.version=5.3.9.133-SNAPSHOT
cfml.version=5.3.9.141
cfml.extensions=8D7FB0DF-08BB-1589-FE3975678F07DB17
cfml.loader.version=2.6.17
cfml.loader.version=2.6.20
cfml.cli.version=${cfml.loader.version}.${cfml.version}
lucee.version=${cfml.version}
# Don't bump this version. Need to remove this dependency from cfmlprojects.org
lucee.config.version=5.2.4.37
jre.version=jdk-11.0.15+10
launch4j.version=3.14
runwar.version=4.7.4
runwar.version=4.7.7
jline.version=3.21.0
jansi.version=2.3.2
jgit.version=5.13.0.202109080827-r
Expand Down
6 changes: 3 additions & 3 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="5.5.1"/>
<property name="commandbox.stableVersion" value="5.5.1"/>
<property name="commandbox.version" value="5.5.2"/>
<property name="commandbox.stableVersion" value="5.5.2"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down Expand Up @@ -1078,7 +1078,7 @@ External Dependencies:

<!-- engine libs -->
<!-- stable builds require "maven-repository", and snapshots require "sonatype-repository" -->
<dependency groupId="org.lucee" artifactId="lucee" version="${lucee.version}" dest="${lib.dir}" unzip="false" type="jar" repoId="sonatype-repository">
<dependency groupId="org.lucee" artifactId="lucee" version="${lucee.version}" dest="${lib.dir}" unzip="false" type="jar" repoId="maven-repository">
<exclusions>
<exclusion groupId="org.apache.ant" artifactId="ant" />
<exclusion groupId="javax.servlet" artifactId="javax.servlet-api" />
Expand Down
3 changes: 3 additions & 0 deletions src/cfml/system/Shell.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,9 @@ component accessors="true" singleton {
// Next check for an Environment Variable called "CI" that is set
} else if( systemSettings.getSystemSetting( 'CI', '__NOT_SET__' ) != '__NOT_SET__' ) {
return false;
// System.console() will return null is the stndin or stndout is not a TTY
} else if( isNull( createObject( 'java', 'java.lang.System' ).console() ) ) {
return false;
// Default to true
} else {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/cfml/system/modules/globber/box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"Globber",
"version":"3.1.1",
"version":"3.1.3",
"author":"Brad Wood",
"homepage":"https://github.com/Ortus-Solutions/globber/",
"documentation":"https://github.com/Ortus-Solutions/globber/",
Expand Down
47 changes: 33 additions & 14 deletions src/cfml/system/modules/globber/models/Globber.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ component accessors="true" {
.filter( (p)=>p.type=='dir' )
.sort( (a,b)=>len(a.directory&a.name )-len(b.directory&b.name ) )
.each( (p)=>{
var newDir = p.directory.listAppend( p.name, '/', false );
var newDir = pathAppend( p.directory, p.name );
newDir = pathPatternMatcher.normalizeSlashes( newDir );
newDir = newDir.replace( getBaseDir(), '' )
directoryCreate( targetPath & newDir, true, true )
Expand Down Expand Up @@ -244,11 +244,7 @@ component accessors="true" {
} else {
return getMatchQuery().reduce( function( arr, row ) {
// Turn all the slashes the right way for this OS
if( row.directory == '/' ) {
return arr.append( row.directory & row.name & ( row.type == 'Dir' ? '/' : '' ) );
} else {
return arr.append( row.directory & '/' & row.name & ( row.type == 'Dir' ? '/' : '' ) );
}
return arr.append( row.directory & '/' & row.name & ( row.type == 'Dir' ? '/' : '' ) );
}, [] );
}
}
Expand Down Expand Up @@ -327,7 +323,7 @@ component accessors="true" {
local.thisPattern = pathPatternMatcher.normalizeSlashes( arguments.pattern );
var exactPattern = thisPattern.startsWith('/');
var fileFilter = '';
var fullPatternPath = ( getLoose() ? getBaseDir().listAppend( thisPattern, '/', false ) : thisPattern );
var fullPatternPath = ( getLoose() ? pathAppend( getBaseDir(), thisPattern ) : thisPattern );

// Optimization for exact file path
if( ( !getLoose() || exactPattern )
Expand All @@ -353,6 +349,7 @@ component accessors="true" {

// Strip off the "not found" part
var remainingPattern = findUnmatchedPattern( thisPattern, baseDir )

var dl = directoryList (
listInfo='query',
recurse=false,
Expand Down Expand Up @@ -390,9 +387,10 @@ component accessors="true" {
for( var possiblePattern in possiblePatterns) {
if( getLoose() ) {
if( possiblePattern.startsWith( '/' ) ) {
// Exact patterns in loose mode like /foo/bar/baz.txt we want to zoom staright down to the
// Exact patterns in loose mode like /foo/bar/baz.txt we want to zoom straight down to the
// deepest folder possible to reduce unnessary recursion.
possiblePattern = getBaseDir().listAppend( possiblePattern, '/', false );
possiblePattern = pathAppend( getBaseDir(), possiblePattern );

var thisBaseDir = calculateBaseDir( possiblePattern );
possiblePattern = possiblePattern.replace( thisBaseDir, '' );
processPattern( possiblePattern, thisBaseDir, true );
Expand Down Expand Up @@ -484,7 +482,7 @@ component accessors="true" {
if( i == pattern.listLen( '/' ) && !pattern.endsWith( '/' ) ) {
break;
}
baseDir = baseDir.listAppend( token, '/', false );
baseDir = pathAppend( baseDir, token );
}

// Unix paths need the leading slash put back
Expand All @@ -496,10 +494,8 @@ component accessors="true" {
if( baseDir.listLen( '/' ) == 1 && baseDir contains ':' ) {
baseDir = baseDir & '/';
}

if( !baseDir.endsWith( '/' ) ) {
baseDir &= '/';
}

baseDir &= '/';
return baseDir;
}

Expand Down Expand Up @@ -605,6 +601,29 @@ component accessors="true" {
}
}
return remainingPattern;
}

/**
* Concatenate a folder or file to an existing base path, taking into account forward or backslashes
* Won't remove leading slashes on *nix.
* If base is an empty string, path is returned untouched.
*
* @base The base path to append to
* @path The path segment or segments to add on to the base
*/
function pathAppend( base, path ) {
if( base == '' ) {
return path;
}
// Ensure trailing slash on base
if( !base.endsWith( '/' ) && !base.endsWith( '\' ) ) {
base &= '/';
}
// Remove any leading slash on path
if( path.startsWith( '/' ) || path.startsWith( '\' ) ) {
path = path.right( -1 );
}
return base & path;
}

}
4 changes: 1 addition & 3 deletions src/cfml/system/modules/semver/box.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name":"Semantic Version",
"version":"1.2.5",
"version":"1.2.6",
"author":"Brad Wood",
"location":"Ortus-Solutions/semanticVersion#v1.2.5",
"homepage":"https://github.com/Ortus-Solutions/semanticVersion/",
"documentation":"https://github.com/Ortus-Solutions/semanticVersion/",
"repository":{
Expand All @@ -14,7 +13,6 @@
"shortDescription":"This is a library that implements npm-style semantic versioning for CFML.",
"type":"modules",
"scripts":{
"postVersion":"package set location='Ortus-Solutions/semanticVersion#v`package version`'",
"onRelease":"publish",
"postPublish":"!git push --follow-tags"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ component aliases='cfpm' {
var interceptData_serverInfo_name = systemSettings.getSystemSetting( 'interceptData.SERVERINFO.name', '' );

if( configService.getSetting( 'server.singleServerMode', false ) && serverService.getServers().count() ){
serverInfo = serverService.getFirstServer().serverInfo;
serverInfo = serverService.getFirstServer();
// If we're running inside of a server-related package script, use that server
} else if( interceptData_serverInfo_name != '' ) {
print.yellowLine( 'Using interceptData to load server [#interceptData_serverInfo_name#]' );
Expand Down
1 change: 1 addition & 0 deletions src/cfml/system/services/CommandService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ component accessors="true" singleton {
property name='ConfigService' inject='ConfigService';
property name='metadataCache' inject='cachebox:metadataCache';
property name='FRTransService' inject='FRTransService';
property name='job' inject='provider:InteractiveJob';

property name='configured' default="false" type="boolean";

Expand Down
69 changes: 45 additions & 24 deletions src/cfml/system/services/ServerService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ component accessors="true" singleton {
variables.system = createObject( 'java', 'java.lang.System' );

// java helpers
java = {
ServerSocket : createObject( "java", "java.net.ServerSocket" )
, File : createObject( "java", "java.io.File" )
, Socket : createObject( "java", "java.net.Socket" )
, InetAddress : createObject( "java", "java.net.InetAddress" )
, LaunchUtil : createObject( "java", "runwar.LaunchUtil" )
variables.java = {
ServerSocket : createObject( "java", "java.net.ServerSocket" ),
File : createObject( "java", "java.io.File" ),
Socket : createObject( "java", "java.net.Socket" ),
InetAddress : createObject( "java", "java.net.InetAddress" ),
LaunchUtil : createObject( "java", "runwar.LaunchUtil" ),
TimeUnit : createObject( "java", "java.util.concurrent.TimeUnit" )
};

// the home directory.
Expand Down Expand Up @@ -308,14 +309,6 @@ component accessors="true" singleton {
var serverJSONToSave = duplicate( serverJSON );
var serverInfo = serverDetails.serverinfo;

systemSettings.expandDeepSystemSettings( serverJSON );
systemSettings.expandDeepSystemSettings( defaults );
// Mix in environment variable overrides like BOX_SERVER_PROFILE
loadOverrides( serverJSON, serverInfo, serverProps.verbose ?: serverJSON.verbose ?: defaults.verbose ?: false );

// Load up our fully-realized server.json-specific env vars into CommandBox's environment
systemSettings.setDeepSystemSettings( serverDetails.serverJSON.env ?: {}, '', '_' );

interceptorService.announceInterception( 'preServerStart', { serverDetails=serverDetails, serverProps=serverProps, serverInfo=serverDetails.serverInfo, serverJSON=serverDetails.serverJSON, defaults=defaults } );

// In case the interceptor changed them
Expand All @@ -324,8 +317,22 @@ component accessors="true" singleton {
defaultServerConfigFile = serverDetails.defaultServerConfigFile;
defaultServerConfigFileDirectory = getDirectoryFromPath( defaultServerConfigFile );

systemSettings.expandDeepSystemSettings( serverJSON );
systemSettings.expandDeepSystemSettings( defaults );

// Mix in environment variable overrides like BOX_SERVER_PROFILE
loadOverrides( serverJSON, serverInfo, serverProps.verbose ?: serverJSON.verbose ?: defaults.verbose ?: false );

// Load up our fully-realized server.json-specific env vars into CommandBox's environment
systemSettings.setDeepSystemSettings( serverDetails.serverJSON.env ?: {}, '', '_' );

// If the server is already running, make sure the user really wants to do this.
if( isServerRunning( serverInfo ) && !(serverProps.force ?: false ) && !(serverProps.dryRun ?: false ) ) {

if( !shell.isTerminalInteractive() ) {
throw( message="Cannot start server [#serverInfo.name#] because it is already running.", detail="Run [server info --verbose] to find out why CommandBox thinks this server is running.", type="commandException" );
}

job.addErrorLog( 'Server "#serverInfo.name#" (#serverInfo.webroot#) is already running @ #serverInfo.openbrowserURL#!' );
job.addErrorLog( 'Overwriting a running server means you won''t be able to use the "stop" command to stop the original one.' );
job.addWarnLog( 'Use the --force parameter to skip this check.' );
Expand Down Expand Up @@ -1416,7 +1423,7 @@ component accessors="true" singleton {
}

if( serverInfo.runwarXNIOOptions.count() ) {
args.append( '--xnio-options=' & serverInfo.runwarXNIOOptions.reduce( ( opts='', k, v ) => opts.listAppend( k & '=' & v ) ) );
args.append( '--xnio-options=' & serverInfo.runwarXNIOOptions.reduce( ( opts='', k, v ) => opts.listAppend( k & '=' & v, ';' ) ) );
}

if( len( serverInfo.allowedExt ) ) {
Expand Down Expand Up @@ -1760,7 +1767,6 @@ component accessors="true" singleton {
line = bufferedReader.readLine();
} // End of inputStream

// When we require Java 8 for CommandBox, we can pass a timeout to waitFor().
serverInfo.exitCode = process.waitFor();

if( serverInfo.exitCode == 0 ) {
Expand Down Expand Up @@ -1833,16 +1839,31 @@ component accessors="true" singleton {
serverInterrupted = true;
// Something bad happened
} catch ( Any e ) {
// When the sleep() is interrupted, it comes as a Lucee NativeException with the message "sleep interrupted"
if( e.message contains 'interrupted' ){
consoleLogger.error( 'Stopping server...' );
shell.setKeepRunning( false );
serverInterrupted = true;
} else {
logger.error( '#e.message# #e.detail#' , e.stackTrace );
consoleLogger.error( '#e.message##chr(10)##e.detail#' );
}
}

// Now it's time to shut-er down
variables.waitingOnConsoleStart = false;
shell.setPrompt();
// Politely ask the server to stop (async)
stop( serverInfo );
// Give it a chance to stop
try {
process.waitFor( 15, java.TimeUnit.SECONDS );
} catch( any e ) {
logger.error( '#e.message# #e.detail#' , e.stackTrace );
consoleLogger.error( '#e.message##chr(10)##e.detail#' );
// Either way, this server is done like dinner
} finally {
variables.waitingOnConsoleStart = false;
shell.setPrompt();
process.destroy();
// "server stop" is never run for a --console start, so make sure this fires.
interceptorService.announceInterception( 'onServerStop', { serverInfo=serverInfo } );
consoleLogger.error( 'Waiting for server process to stop: #e.message##chr(10)##e.detail#' );
}
// Ok, you're done NOW!
process.destroy();
}

thread action="join" name="#threadName#";
Expand Down
15 changes: 11 additions & 4 deletions src/cfml/system/util/ConsolePainter.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ component singleton accessors=true {
lock timeout="20" name="ConsolePainter" type="exclusive" {
if( getActive() ) {
getFuture().cancel();
try {
getFuture().get();
} catch(any e) {
// Throws CancellationException
}
setActive( false );
clear();
}
Expand Down Expand Up @@ -133,9 +138,11 @@ component singleton accessors=true {
);

} catch( any e ) {
systemoutput( e.message & ' ' & e.detail, 1 );
systemoutput( "#e.tagContext[1].template#: line #e.tagContext[1].line#", 1 );
rethrow;
if( !(e.type contains 'interrupted') ) {
systemoutput( e.message & ' ' & e.detail, 1 );
systemoutput( "#e.tagContext[1].template#: line #e.tagContext[1].line#", 1 );
rethrow;
}
}
}

Expand All @@ -144,7 +151,7 @@ component singleton accessors=true {
*/
function clear() {
display.resize( terminal.getHeight(), terminal.getWidth() );

sleep(100)
display.update(
[ attr.init( ' ' ) ,attr.init( ' ' ) ,attr.init( ' ' ) ,attr.init( ' ' ) ],
0
Expand Down

0 comments on commit 589e058

Please sign in to comment.