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 10, 2017
2 parents 500dbfb + 1c500dc commit f1b7513
Show file tree
Hide file tree
Showing 25 changed files with 340 additions and 221 deletions.
4 changes: 2 additions & 2 deletions build/brew-template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def install
end

test do
system "box", "--commandbox_home=~/", "version"
system "box", "--commandbox_home=~/", "help"
system "#{bin}/box", "--commandbox_home=~/", "version"
system "#{bin}/box", "--commandbox_home=~/", "help"
end
end
6 changes: 3 additions & 3 deletions build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ java.debug=true

#dependencies
dependencies.dir=${basedir}/lib
cfml.version=4.5.4.017
cfml.loader.version=1.4.6
cfml.version=4.5.5.006
cfml.loader.version=1.4.7
cfml.cli.version=${cfml.loader.version}.${cfml.version}
lucee.version=${cfml.version}
jre.version=1.8.0_102
launch4j.version=3.4
runwar.version=3.5.0
runwar.version=3.6.0-SNAPSHOT

#build locations
build.type=localdev
Expand Down
4 changes: 2 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="3.5.0"/>
<property name="commandbox.stableVersion" value="3.5.0"/>
<property name="commandbox.version" value="3.6.0"/>
<property name="commandbox.stableVersion" value="3.6.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down
2 changes: 1 addition & 1 deletion src/cfml/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ component{

this.name = "CommandBox CLI";
this.sessionmanagement = "false";
this.applicationTimeout = createTimeSpan( 7, 0, 0, 0 );
this.applicationTimeout = createTimeSpan( 999999, 0, 0, 0 );

// Move everything over to this mapping which is the "root" of our app
CFMLRoot = getDirectoryFromPath( getMetadata( this ).path );
Expand Down
2 changes: 1 addition & 1 deletion src/cfml/system/Bootstrap.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ I am a CFM because the CLI seems to need a .cfm file to call
This file will stay running the entire time the shell is open
--->
<cfset variables.wireBox = application.wireBox>
<cfsetting requesttimeout="999999" />
<cfsetting requesttimeout="86399913600" /><!--- 999999 days --->
<!---Display this banner to users--->
<cfoutput><cfsavecontent variable="banner">#chr( 27 )#[32m#chr( 27 )#[40m#chr( 27 )#[1m
_____ _ ____
Expand Down
10 changes: 6 additions & 4 deletions src/cfml/system/Shell.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ component accessors="true" singleton {
if( ! ( lastChar == chr( 10 ) || lastChar == chr( 13 ) ) ) {
variables.reader.println();
}
} else {
variables.reader.println();
}

return '';
Expand Down Expand Up @@ -563,11 +565,11 @@ component accessors="true" singleton {
if( lines != 0 ){
for( var idx=1; idx <= lines; idx++) {
var tc = arguments.err.tagcontext[ idx ];
if( idx > 1 ) {
variables.reader.print( print.boldCyanText( "called from " ) );
}
variables.reader.print( variables.print.boldCyanText( "#tc.template#: line #tc.line##variables.cr#" ));
if( len( tc.codeprinthtml ) ){
if( idx > 1 ) {
variables.reader.print( print.boldCyanText( "called from " ) );
}
variables.reader.print( variables.print.boldCyanText( "#tc.template#: line #tc.line##variables.cr#" ));
variables.reader.print( variables.print.text( variables.formatterUtil.HTML2ANSI( tc.codeprinthtml ) ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ component {

// Map these shortcut names to the actual ForgeBox slugs
variables.templateMap = {
Advanced = 'cbtemplate-advanced',
AdvancedScript = 'cbtemplate-advanced-script',
ElixirVueJS = 'cbtemplate-elixir-vuejs',
ElixirBower = 'cbtemplate-elixir-bower',
Elixir = 'cbtemplate-elixir',
rest = 'cbtemplate-rest',
Simple = 'cbtemplate-simple',
SuperSimple = 'cbtemplate-supersimple'
'Advanced' = 'cbtemplate-advanced',
'AdvancedScript' = 'cbtemplate-advanced-script',
'ElixirVueJS' = 'cbtemplate-elixir-vuejs',
'ElixirBower' = 'cbtemplate-elixir-bower',
'Elixir' = 'cbtemplate-elixir',
'rest' = 'cbtemplate-rest',
'Simple' = 'cbtemplate-simple',
'SuperSimple' = 'cbtemplate-supersimple'
};

return this;
}

/**
* @name The name of the app you want to create
* @skeleton The name of the app skeleton to generate
* @skeleton The name of the app skeleton to generate (or an endpoint ID like a forgebox slug)
* @skeleton.optionsUDF skeletonComplete
* @directory The directory to create the app in and creates the directory if it does not exist. Defaults to your current working directory.
* @init "init" the directory as a package if it isn't already
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
void function |interceptionPoint|( event, rc, pc, interceptData, buffer ){
void function |interceptionPoint|( event, rc, prc, interceptData, buffer ){

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ component {
function postModuleLoad() { processScripts( 'postModuleLoad' ); }
function preModuleUnLoad() { processScripts( 'preModuleUnLoad' ); }
function postModuleUnload() { processScripts( 'postModuleUnload' ); }

function preServerStart() { processScripts( 'preServerStart' ); }
function onServerInstall() { processScripts( 'onServerInstall', interceptData.serverinfo.webroot ); }
function onServerStart() { processScripts( 'onServerStart', interceptData.serverinfo.webroot ); }
function onServerStop() { processScripts( 'onServerStop', interceptData.serverinfo.webroot ); }
function preServerForget() { processScripts( 'preServerForget', interceptData.serverinfo.webroot ); }
function postServerForget() { processScripts( 'postServerForget', interceptData.serverinfo.webroot ); }

function onException() { processScripts( 'onException' ); }

// preInstall gets package requesting the installation because dep isn't installed yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ component {
"Really forget & delete server '#serverinfo.name#' forever [y/n]?";

if( arguments.force || confirm( askMessage ) ){
print.line( serverService.forget( serverInfo, arguments.all ) );
servers.each( function( ID ){
print
.line( serverService.forget( servers[ arguments.ID ] ) )
.toConsole();
} );
} else {
print.orangeLine( "Cancelling forget command" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ component {

print.indentedLine( "host: " & thisServerInfo.host );
if( len( thisServerInfo.engineName ) ) {
print.indentedLine( "CF Engine: " & thisServerInfo.engineName & ' ' & serverInfo.engineVersion );
print.indentedLine( "CF Engine: " & thisServerInfo.engineName & ' ' & thisServerInfo.engineVersion );
}
if( len( thisServerInfo.WARPath ) ) {
print.indentedLine( "WARPath: " & thisServerInfo.WARPath );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ component aliases='status,server info' {

print.indentedLine( trim( thisServerInfo.statusInfo.command ) );
// Put each --arg or -arg on a new line
var args = trim( replaceNoCase( thisServerInfo.statusInfo.arguments, ' -', cr & '-', 'all' ) );
var args = trim( reReplaceNoCase( thisServerInfo.statusInfo.arguments, ' (-|"-)', cr & '\1', 'all' ) );
print.indentedIndentedLine( args )
.line();

Expand Down
65 changes: 23 additions & 42 deletions src/cfml/system/modules_app/system-commands/commands/run.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Execute an operating system level command in the native shell. The binary must be in the PATH, or you can specify the full
* path to it. This command will wait for the OS exectuable to complete. This cannot be used for any commands that require
* interactivity or don't exit automatically or the call will hang indefinitely.
* path to it. This command will wait for the OS exectuable to complete but will flush the output as it is received.
* .
* {code:bash}
* run myApp.exe
Expand Down Expand Up @@ -47,57 +46,39 @@ component{
function run(
required command
){

var executeResult = "";
var executeError = "";

// Prep the command to run in the OS-specific shell
if( fileSystemUtil.isWindows() ) {
// Pass through Windows' command shell, /a outputs ANSI formatting, /c runs as a command
arguments.command = [ 'cmd','/a','/c', arguments.command ];
var commandArray = [ 'cmd','/a','/c', arguments.command ];
} else {
// Pass through bash in interactive mode to expand aliases like "ll".
// -c runs input as a command, && exists cleanly from the shell as long as the original command ran successfully
// Pass through bash in interactive mode with -i to expand aliases like "ll".
// -c runs input as a command, "&& exits" cleanly from the shell as long as the original command ran successfully
var nativeShell = configService.getSetting( 'nativeShell', '/bin/bash' );
arguments.command = [ nativeShell,'-i','-c', arguments.command & ' && exit'];
commandArray = [ nativeShell, '-i', '-c', arguments.command & ' && ( exit $? > /dev/null )' ];
}

try{
// grab the current working directory
var pwd = fileSystemUtil.resolvePath( '' );
var CWD = createObject( 'java', 'java.io.File' ).init( pwd );

// execute the server command
var process = createObject( 'java', 'java.lang.Runtime' )
.getRuntime()
.exec( '#arguments.command#', javaCast( "null", "" ), CWD );
var commandResult = createObject( 'java', 'lucee.commons.cli.Command' )
.execute( process );

// I don't like the idea of potentially removing significant whitespace, but commands like pwd
// come with an extra line break that is a pain if you want to pipe into another command
var executeResult = trim( commandResult.getOutput() );
var executeError = trim( commandResult.getError() );

// Output Results
if( !isNull( executeResult ) && len( executeResult ) ) {
print.Text( executeResult );
}
// Output error
if( !isNull( executeError ) && len( executeError ) ) {
// Clean up standard error from Unix interactive shell workaround
if( !fileSystemUtil.isWindows() && right( executeError, 4 ) == 'exit' ) {
executeError = mid( executeError, 1, len( executeError )-4 );
}
// Clean up annoying warnings abour job control in some shells.
if( !fileSystemUtil.isWindows() && findNoCase( 'bash: no job control in this shell', executeError ) ) {
executeError = replaceNoCase( executeError, 'bash: no job control in this shell', '' );
executeError = trim( executeError );
}
print.redText( executeError );
}
var CWDFile = createObject( 'java', 'java.io.File' ).init( fileSystemUtil.resolvePath( '' ) );
var exitCode = createObject( "java", "java.lang.ProcessBuilder" )
.init( commandArray )
// Do you believe in magic
// This works great on Mac/Windows.
// On Linux, the standard input (keyboard) is not being piped to the background process.
.inheritIO()
// Sets current working directory for the process
.directory( CWDFile )
// Fires process async
.start()
// waits for it to exit, returning the exit code
.waitFor();

if( exitCode != 0 ) {
error( 'Command returned failing exit code [#exitCode#]' );
}

} catch (any e) {
} catch( any e ){
error( '#e.message##CR##e.detail#' );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ component {
print.green( " " & results.filecontent );
} else if( results.responseheader[ "x-testbox-totalFail" ] gt 0 ){
// print Failure report
setExitCode( 1 );
print.yellow( " " & results.filecontent );
} else if( results.responseheader[ "x-testbox-totalError" ] gt 0 ){
// print Failure report
Expand Down
10 changes: 5 additions & 5 deletions src/cfml/system/services/CommandService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ component accessors="true" singleton {

interceptorService.announceInterception( 'preCommand', { commandInfo=commandInfo, parameterInfo=parameterInfo } );

// Successful command execution resets exit code to 0. Set this prior to running the command since the command
// may explicitly set the exit code to 1 but not call the error() method.
shell.setExitCode( 0 );

// Run the command
try {
var result = commandInfo.commandReference.CFC.run( argumentCollection = parameterInfo.namedParameters );
Expand Down Expand Up @@ -321,9 +325,6 @@ component accessors="true" singleton {
}
}

// Successful command execution resets exit code to 0
shell.setExitCode( 0 );

// Remove it from the stack
instance.callStack.deleteAt( 1 );

Expand All @@ -340,7 +341,6 @@ component accessors="true" singleton {
result = interceptData.result;

} // End loop over command chain

return result;

}
Expand Down Expand Up @@ -703,7 +703,7 @@ component accessors="true" singleton {
var commandData = createCommandData( fullCFCPath, commandName );
// This will catch nasty parse errors so the shell can keep loading
} catch( any e ){
systemOutput( 'Error registering command [#fullCFCPath#] #CR#' );
systemOutput( 'Error registering command [#fullCFCPath#] #CR##e.message# #e.detail ?: ''##CR#Check the logs with [system-log | open] for more info.', true );
logger.error( 'Error registering command [#fullCFCPath#]. #e.message# #e.detail ?: ''#', e.stackTrace );
// pretty print the exception
// shell.printError( e );
Expand Down
2 changes: 1 addition & 1 deletion src/cfml/system/services/InterceptorService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ component accessors=true singleton {
// Module lifecycle
'preModuleLoad','postModuleLoad','preModuleUnLoad','postModuleUnload',
// Server lifecycle
'preServerStart','onServerStart','onServerInstall','onServerStop',
'preServerStart','onServerStart','onServerInstall','onServerStop','preServerForget','postServerForget',
// Error handling
'onException',
// Package lifecycle
Expand Down
8 changes: 7 additions & 1 deletion src/cfml/system/services/ModuleService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@
for( var moduleName in modules ){
// Verify the exception and inclusion lists
if( canLoad( moduleName ) ){
activateModule( moduleName );
try {
activateModule( moduleName );
} catch( any var e ) {
systemOutput( 'Module [#moduleName#] failed to load! Check the logs for more info.', true );
systemOutput( e.message & chr( 10 ) & (e.detail ?: '') , true );
instance.logger.error( 'Module [#moduleName#] failed to load!', e );
}
}
}
</cfscript>
Expand Down
Loading

0 comments on commit f1b7513

Please sign in to comment.