Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Apr 29, 2022
2 parents 12ea688 + 1c6a64e commit 3302bdd
Show file tree
Hide file tree
Showing 73 changed files with 2,041 additions and 746 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Auto detect text files and perform LF normalization
.sh eol=lf
* text=auto

# Custom for Visual Studio
Expand Down
1 change: 1 addition & 0 deletions .github/FUNDING.YML
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: ortussolutions
12 changes: 6 additions & 6 deletions build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ java.debug=true

#dependencies
dependencies.dir=${basedir}/lib
cfml.version=5.3.8.206
cfml.version=5.3.9.133-SNAPSHOT
cfml.extensions=8D7FB0DF-08BB-1589-FE3975678F07DB17
cfml.loader.version=2.6.5
cfml.loader.version=2.6.16
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.12+7
jre.version=jdk-11.0.15+10
launch4j.version=3.14
runwar.version=4.5.2
jline.version=3.19.0
runwar.version=4.7.4
jline.version=3.21.0
jansi.version=2.3.2
jgit.version=5.11.0.202103091610-r
jgit.version=5.13.0.202109080827-r

#build locations
build.type=localdev
Expand Down
31 changes: 17 additions & 14 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.4.2"/>
<property name="commandbox.stableVersion" value="5.4.2"/>
<property name="commandbox.version" value="5.5.0"/>
<property name="commandbox.stableVersion" value="5.5.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down Expand Up @@ -382,9 +382,9 @@ External Dependencies:
</fileset>
<fileset file="${temp.dir}/cli/luceecli.jar" />
<fileset file="${temp.dir}/cli/ortus-jgit.jar" />
<fileset file="${src.dir}/resources/log4j2.xml" />
</zip>


<zip destfile="${temp.dir}/cli-light/libs.zip">
<fileset dir="${lucee-light.lib.dir}">
<include name="**/*.jar"/>
Expand All @@ -394,6 +394,7 @@ External Dependencies:
</fileset>
<fileset file="${temp.dir}/cli/luceecli.jar" />
<fileset file="${temp.dir}/cli/ortus-jgit.jar" />
<fileset file="${src.dir}/resources/log4j2.xml" />
</zip>

<!-- </else>
Expand Down Expand Up @@ -730,7 +731,7 @@ External Dependencies:
chdir="%OLDPWD%"
icon="${src.dir}/resources/box.ico"
stayAlive="true">
<jre path="./jre/" minVersion="1.8.0" />
<jre path="./jre/;%JAVA_HOME%;%JRE_HOME%;%JDK_HOME%;%PATH%" minVersion="1.8.0" maxVersion="15.0.0" />
<versionInfo fileVersion="${commandbox.version.noPrereleaseID}.0"
txtFileVersion="${commandbox.version}.${build.number}"
fileDescription="${commandbox.description}"
Expand Down Expand Up @@ -818,7 +819,7 @@ External Dependencies:

<mkdir dir="JREs/jre_${jre.version}_linux_x64"/>

<get src="https://api.adoptopenjdk.net/v3/binary/version/${jre.version.escaped}/linux/x64/jre/hotspot/normal/adoptopenjdk"
<get src="https://api.adoptium.net/v3/binary/version/${jre.version.escaped}/linux/x64/jre/hotspot/normal/eclipse"
dest="JREs/jre_${jre.version}_linux_x64.tar.gz"
verbose="true" />

Expand All @@ -836,25 +837,25 @@ External Dependencies:

<mkdir dir="JREs/jre_${jre.version}_windows_x64"/>

<get src="https://api.adoptopenjdk.net/v3/binary/version/${jre.version.escaped}/windows/x64/jre/hotspot/normal/adoptopenjdk"
<get src="https://api.adoptium.net/v3/binary/version/${jre.version.escaped}/windows/x64/jre/hotspot/normal/eclipse"
dest="JREs/jre_${jre.version}_windows_x64.zip"
verbose="true" />
<unzip src="JREs/jre_${jre.version}_windows_x64.zip" dest="JREs\jre_${jre.version}_windows_x64/" overwrite="true"/>
</else>
</antcontrib:if>

<antcontrib:if>
<available file="JREs/jre_${jre.version}_windows_x32.zip" />
<available file="JREs/jre_jdk-11.0.14.1+1_windows_x32.zip" />
<then><echo>Windows x32 JRE found!</echo></then>
<else>
<echo>Windows x32 JRE not found, downloading artifact</echo>

<mkdir dir="JREs/jre_${jre.version}_windows_x32"/>
<mkdir dir="JREs/jre_jdk-11.0.14.1+1_windows_x32"/>

<get src="https://api.adoptopenjdk.net/v3/binary/version/${jre.version.escaped}/windows/x32/jre/hotspot/normal/adoptopenjdk"
dest="JREs/jre_${jre.version}_windows_x32.zip"
<get src="https://api.adoptium.net/v3/binary/version/jdk-11.0.14.1%2B1/windows/x32/jre/hotspot/normal/eclipse"
dest="JREs/jre_jdk-11.0.14.1+1_windows_x32.zip"
verbose="true" />
<unzip src="JREs/jre_${jre.version}_windows_x32.zip" dest="JREs\jre_${jre.version}_windows_x32/" overwrite="true"/>
<unzip src="JREs/jre_jdk-11.0.14.1+1_windows_x32.zip" dest="JREs\jre_jdk-11.0.14.1+1_windows_x32/" overwrite="true"/>
</else>
</antcontrib:if>

Expand All @@ -866,7 +867,7 @@ External Dependencies:

<mkdir dir="JREs/jre_${jre.version}_mac_x64"/>

<get src="https://api.adoptopenjdk.net/v3/binary/version/${jre.version.escaped}/mac/x64/jre/hotspot/normal/adoptopenjdk"
<get src="https://api.adoptium.net/v3/binary/version/${jre.version.escaped}/mac/x64/jre/hotspot/normal/eclipse"
dest="JREs/jre_${jre.version}_mac_x64.tar.gz"
verbose="true" />

Expand All @@ -879,7 +880,7 @@ External Dependencies:

<!--Zip Box Binary With JRE -->
<zip destfile="${dist.dir}/${distro.name}-jre-win32-${commandbox.version}.zip" level="9" update="true">
<zipfileset prefix="jre" dir="JREs\jre_${jre.version}_windows_x32/${jre.version}-jre/"/>
<zipfileset prefix="jre" dir="JREs\jre_jdk-11.0.14.1+1_windows_x32/jdk-11.0.14.1+1-jre/"/>
<fileset file="${dist.dir}/box.exe" />
</zip>
<zip destfile="${dist.dir}/${distro.name}-jre-win64-${commandbox.version}.zip" level="9" update="true">
Expand Down Expand Up @@ -1077,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="maven-repository">
<dependency groupId="org.lucee" artifactId="lucee" version="${lucee.version}" dest="${lib.dir}" unzip="false" type="jar" repoId="sonatype-repository">
<exclusions>
<exclusion groupId="org.apache.ant" artifactId="ant" />
<exclusion groupId="javax.servlet" artifactId="javax.servlet-api" />
Expand All @@ -1086,6 +1087,8 @@ External Dependencies:
<exclusion groupId="org.apache.felix" artifactId="org.apache.felix.framework" />
<exclusion groupId="junit" artifactId="junit" />
<exclusion groupId="org.lucee.lib" artifactId="slf4j-nop" />
<exclusion groupId="org.lucee" artifactId="log4j-core" />
<exclusion groupId="org.lucee" artifactId="log4j-api" />
</exclusions>
</dependency>

Expand Down
8 changes: 4 additions & 4 deletions src/cfml/system/BaseCommand.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ component accessors="true" singleton {
function error( required message, detail='', clearPrintBuffer=false, exitCode=1 ) {

wirebox.getInstance( "ConsolePainter" ).stop( message );
print.line().toConsole();

if( !getSystemSetting( 'box_currentCommandPiped', false ) ) {
print.line().toConsole();
}

setExitCode( arguments.exitCode );
if( arguments.clearPrintBuffer ) {
// Wipe
print.clear();
} else {
// Distance ourselves from whatever other output the command may have given so far.
print.line();
}
throw( message=arguments.message, detail=arguments.detail, type="commandException", errorcode=arguments.exitCode );
}
Expand Down
91 changes: 68 additions & 23 deletions src/cfml/system/Shell.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ component accessors="true" singleton {
setTempDir( variables.tempdir );

getInterceptorService().configure();
getInterceptorService().registerInterceptor(
interceptor = endpointService,

getInterceptorService().registerInterceptor(
interceptor = endpointService,
interceptorObject = endpointService,
interceptorName = "endpoint-service"
);
Expand All @@ -163,13 +163,13 @@ component accessors="true" singleton {
} else {
variables.commandService.configure();
}

// Ensure we have a system box.json
var systemBoxJSON = expandPath( '/commandbox/box.json' );
if( !fileExists( systemBoxJSON ) ) {
fileWrite( systemBoxJSON, '{ "name":"CommandBox System" }' );
}

}


Expand Down Expand Up @@ -439,7 +439,7 @@ component accessors="true" singleton {
* Get's terminal width
**/
function getTermWidth() {
return variables.reader.getTerminal().getWidth();
return configService.getSetting( "terminalWidth", variables.reader.getTerminal().getWidth() );
}

/**
Expand Down Expand Up @@ -485,6 +485,10 @@ component accessors="true" singleton {
* @directory.hint directory to CD to. Please verify it exists before calling.
**/
String function cd( directory="" ){
// Ensure we have a trailing slash for our directory.
if( !(arguments.directory.endsWith( '/' ) || arguments.directory.endsWith( '\' ) ) ) {
arguments.directory &= '/';
}
variables.pwd = arguments.directory;
request.lastCWD = arguments.directory;
// Update prompt to reflect directory change
Expand Down Expand Up @@ -542,14 +546,22 @@ component accessors="true" singleton {

var terminal = getReader().getTerminal();
if( terminal.paused() ) {
terminal.resume();
terminal.resume();
}

// Shell stops on this line while waiting for user input
if( arguments.silent ) {
line = variables.reader.readLine( interceptData.prompt, javacast( "char", ' ' ) );
param request.developerModeReloading = false;
param request.developerModeCommand='';
if( len( request.developerModeCommand) ) {
line = request.developerModeCommand;
request.developerModeReloading=true;
request.developerModeCommand = '';
} else {
line = variables.reader.readLine( interceptData.prompt );
// Shell stops on this line while waiting for user input
if( arguments.silent ) {
line = variables.reader.readLine( interceptData.prompt, javacast( "char", ' ' ) );
} else {
line = variables.reader.readLine( interceptData.prompt );
}
}

// User hits Ctrl-C. Don't let them exit the shell.
Expand Down Expand Up @@ -598,6 +610,21 @@ component accessors="true" singleton {

// If there's input, try to run it.
if( len( trim( line ) ) ) {

param request.developerModeReloaded = false;
if( configService.getSetting( 'developerMode', false ) && !request.developerModeReloading ){
// If we've never reloaded, the CLI just started, so just clear the cache
if( !request.developerModeReloaded ){
wirebox.getCacheBox().getCache( 'metadataCache' ).clearAll();
request.developerModeReloaded = true;
} else {
request.developerModeCommand = line;
reload( clear=false );
return true;
}
}
request.developerModeReloading=false;

var interceptData = {
line : line
}
Expand Down Expand Up @@ -749,17 +776,19 @@ component accessors="true" singleton {

/**
* Call a command
* @command.hint Either a string containing a text command, or an array of tokens representing the command and parameters.
* @returnOutput.hint True will return the output of the command as a string, false will send the output to the console. If command outputs nothing, an empty string will come back.
* @piped.hint Any text being piped into the command. This will overwrite the first parameter (pushing any positional params back)
* @initialCommand.hint Since commands can recursively call new commands via this method, this flags the first in the chain so exceptions can bubble all the way back to the beginning.
* @command Either a string containing a text command, or an array of tokens representing the command and parameters.
* @returnOutput True will return the output of the command as a string, false will send the output to the console. If command outputs nothing, an empty string will come back.
* @piped Any text being piped into the command. This will overwrite the first parameter (pushing any positional params back)
* @initialCommand Since commands can recursively call new commands via this method, this flags the first in the chain so exceptions can bubble all the way back to the beginning.
* @line If passing an array of tokens, this is the original, unparsed line typed by the user
* In other words, if "foo" calls "bar", which calls "baz" and baz errors, all three commands are scrapped and do not finish execution.
**/
function callCommand(
required any command,
returnOutput=false,
string piped,
boolean initialCommand=false ) {
boolean initialCommand=false,
string line ) {

var job = wirebox.getInstance( 'interactiveJob' );
var ConsolePainter = wirebox.getInstance( 'ConsolePainter' );
Expand All @@ -778,10 +807,13 @@ component accessors="true" singleton {
try{

if( isArray( command ) ) {
if( isNull( arguments.line ) ) {
arguments.line = command.toList( ' ' );
}
if( structKeyExists( arguments, 'piped' ) ) {
var result = variables.commandService.runCommandTokens( arguments.command, piped, returnOutput );
var result = variables.commandService.runCommandTokens( arguments.command, piped, returnOutput, line );
} else {
var result = variables.commandService.runCommandTokens( tokens=arguments.command, captureOutput=returnOutput );
var result = variables.commandService.runCommandTokens( tokens=arguments.command, captureOutput=returnOutput, line=line );
}
} else {
var result = variables.commandService.runCommandLine( arguments.command, returnOutput );
Expand All @@ -796,7 +828,7 @@ component accessors="true" singleton {

ConsolePainter.forceStop();

printError( { message : e.message, detail: e.detail } );
printError( { message : e.message, detail: e.detail, extendedInfo : e.extendedInfo ?: '' } );
}
// This type of error means the user hit Ctrl-C, during a readLine() call. Duck out and move along.
} catch (any e) {
Expand All @@ -817,7 +849,7 @@ component accessors="true" singleton {
job.reset();
variables.reader.getTerminal().writer().flush();
variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().print( variables.print.boldRedLine( 'CANCELLED' ) );
variables.reader.getTerminal().writer().print( variables.print.boldRedLine( 'CANCELLED' ) );
}
// Anything else is completely unexpected and means boom booms happened-- full stack please.
} else {
Expand Down Expand Up @@ -891,6 +923,13 @@ component accessors="true" singleton {
setExitCode( 1 );
}

if( !isNull( err.extendedInfo ) && isJSON( err.extendedInfo ) ){
var info = deserializeJSON( err.extendedInfo );
if( info.keyExists( 'commandOutput' ) ) {
variables.reader.getTerminal().writer().print( info.commandOutput );
}
}

var verboseErrors = true;
try{
verboseErrors = configService.getSetting( 'verboseErrors', false );
Expand All @@ -901,11 +940,17 @@ component accessors="true" singleton {
getInterceptorService().announceInterception( 'onException', { exception=err } );
}

variables.logger.error( '#arguments.err.message# #arguments.err.detail ?: ''#', arguments.err.stackTrace ?: '' );
variables.logger.error( '#arguments.err.message ?: ''# #arguments.err.detail ?: ''#', arguments.err.stackTrace ?: '' );

variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().print( variables.print.whiteOnRedLine( 'ERROR (#variables.version#)' ) );
variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().println( variables.print.boldRedText( variables.formatterUtil.HTML2ANSI( arguments.err.message, 'boldRed' ) ) );
if( isNull( arguments.err.message ) ) {
variables.reader.getTerminal().writer().println( variables.print.boldRedText( variables.formatterUtil.HTML2ANSI( arguments.err.type, 'boldRed' ) ) );
} else {
variables.reader.getTerminal().writer().println( variables.print.boldRedText( variables.formatterUtil.HTML2ANSI( arguments.err.message, 'boldRed' ) ) );
}

try{

Expand All @@ -919,7 +964,7 @@ component accessors="true" singleton {
while( !isNull( cause ) ) {
// If the nested exception has the same type as the outer exception and no message, there's no value in it here. (Lucee's nesting of IOExceptions can do this)
// Or if there are two levels of causes with the same type and Message. (RabbitMQ's Java client does this)
if( (cause.getClass().getName() == arguments.err.message && isNull( cause.getMessage() ) )
if( (cause.getClass().getName() == ( arguments.err.message ?: '' ) && isNull( cause.getMessage() ) )
|| ( cause.getClass().getName() == previousType && previousMessage == cause.getMessage() ?: '' ) ) {
// move the pointer and move on
cause = cause.getCause();
Expand Down
6 changes: 6 additions & 0 deletions src/cfml/system/endpoints/CFLib.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ component accessors="true" implements="IEndpoint" singleton {
property name="progressBar" inject="ProgressBar";
property name="CR" inject="CR@constants";
property name='wirebox' inject='wirebox';
property name='configService' inject='configService';

// Properties
property name="namePrefixes" type="string";
Expand All @@ -27,6 +28,11 @@ component accessors="true" implements="IEndpoint" singleton {
}

public string function resolvePackage( required string package, boolean verbose=false ) {

if( configService.getSetting( 'offlineMode', false ) ) {
throw( 'Can''t download [#getNamePrefixes()#:#package#], CommandBox is in offline mode. Go online with [config set offlineMode=false].', 'endpointException' );
}

var job = wirebox.getInstance( 'interactiveJob' );
var folderName = tempDir & '/' & 'temp#createUUID()#';
var fullPath = folderName & '/' & package & '.cfm';
Expand Down
Loading

0 comments on commit 3302bdd

Please sign in to comment.