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 Aug 14, 2017
2 parents e477e09 + 06a3f09 commit 8b4f197
Show file tree
Hide file tree
Showing 21 changed files with 402 additions and 81 deletions.
2 changes: 1 addition & 1 deletion build/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java.debug=true
#dependencies
dependencies.dir=${basedir}/lib
cfml.version=4.5.5.006
cfml.loader.version=1.5.4
cfml.loader.version=1.5.5
cfml.cli.version=${cfml.loader.version}.${cfml.version}
lucee.version=${cfml.version}
jre.version=1.8.0_102
Expand Down
5 changes: 3 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.7.0"/>
<property name="commandbox.stableVersion" value="3.7.0"/>
<property name="commandbox.version" value="3.8.0"/>
<property name="commandbox.stableVersion" value="3.8.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down Expand Up @@ -821,6 +821,7 @@ External Dependencies:
<dependency groupId="org.lucee" artifactId="lucee" version="${lucee.version}" dest="${lucee.lib.dir}" unzip="false" type="jar">
<exclusions>
<exclusion groupId="org.lucee.lib" artifactId="railo-slf4j" />
<exclusion groupId="org.lucee.lib" artifactId="slf4j-nop" />
</exclusions>
</dependency>
<dependency groupId="org.lucee" artifactId="lucee.optional" version="${lucee.version}"
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Download from the [Ortus Integration Repository](http://integration.stg.ortussol
Get going with CommandBox in a matter of minutes with our [Getting Started Guide](http://ortus.gitbooks.io/commandbox-documentation/content/getting_started_guide.html)
**Bug Tracker**
Found an issue? Check out [Bug Tracker](https://ortussolutions.atlassian.net/browse/COMMANDBOX)
## DOCUMENTATION
Expand Down
31 changes: 30 additions & 1 deletion src/cfml/system/BaseTask.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,35 @@
*/
component accessors="true" extends='commandbox.system.BaseCommand' {

// For now, tasks just do everything commands do
// 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;
}

}
5 changes: 5 additions & 0 deletions src/cfml/system/Interceptor.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@ component accessors="true"{
return this;
}

// Convenience method for getting stuff from WireBox
function getInstance( name, dsl, initArguments={}, targetObject='' ) {
return getWirebox().getInstance( argumentCollection = arguments );
}

}
14 changes: 11 additions & 3 deletions src/cfml/system/endpoints/ForgeBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,14 @@ component accessors="true" implements="IEndpointInteractive" singleton {
* @package The full endpointID like foo@1.0.0
*/
public function parseSlug( required string package ) {
return listFirst( arguments.package, '@' );
var matches = REFindNoCase( "^((?:@[\w\-]+\/)?[\w\-]+)(?:@(.+))?", package, 1, true );
if ( arrayLen( matches.len ) < 2 ) {
throw(
type = "endpointException",
message = "Invalid slug detected. Slugs can only contain letters, numbers, underscores, and hyphens. They may also be prepended with an @ sign for private packages"
);
}
return mid( package, matches.pos[ 2 ], matches.len[ 2 ] );
}

/**
Expand All @@ -316,10 +323,11 @@ component accessors="true" implements="IEndpointInteractive" singleton {
public function parseVersion( required string package ) {
var version = 'stable';
// [email protected]
if( arguments.package contains '@' ) {
var matches = REFindNoCase( "^((?:@[\w\-]+\/)?[\w\-]+)(?:@(.+))?", package, 1, true );
if ( matches.pos.len() >= 3 && matches.pos[ 3 ] != 0 ) {
// Note this can also be a semver range like 1.2.x, >2.0.0, or 1.0.4-2.x
// For now I'm assuming it's a specific version
version = listRest( arguments.package, '@' );
version = mid( package, matches.pos[ 3 ], matches.len[ 3 ] );
}
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ component extends="app" {

/**
* @name The name of the app you want to create
* @skeleton The application skeleton you want to use
* @skeleton The application skeleton you want to use (Advanced, AdvancedScript, rest, Simple, SuperSimple)
* @skeleton.optionsUDF skeletonComplete
* @init Would you like to init this as a CommandBox Package
* @installColdBox Install the latest stable version of ColdBox from ForgeBox
Expand All @@ -16,8 +16,6 @@ component extends="app" {
required name,
required skeleton,
required boolean init,
required boolean installColdBox,
required boolean installColdBoxBE,
required boolean installTestBox
) {
var skeletons = skeletonComplete();
Expand All @@ -26,6 +24,11 @@ component extends="app" {
arguments.initWizard = true;
arguments.directory = getCWD();

if( !arguments.skeleton.len() ) {
// Remove if empty so it can default correctly
arguments.delete( 'skeleton' );
}

super.run( argumentCollection=arguments );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* The default generator used is 'native'
* .
* To generate properties you will pass a list of property names to the 'properties' argument. You can also add
* ORM types to the properties by separating them with a semicolon. For example:
* ORM types to the properties by separating them with a colon. For example:
* {code:bash}
* properties=name,createDate:timestamp,age:numeric
* {code}
Expand Down Expand Up @@ -39,7 +39,7 @@ component {
* @primaryKeyColumn Enter the name of the primary key column. Leave empty if same as the primaryKey value
* @generator Enter the ORM key generator to use, defaults to 'native'
* @generator.options increment,identity,sequence,native,assigned,foreign,seqhilo,uuid,guid,select,sequence-identiy
* @properties Enter a list of properties to generate. You can add the ORM type via semicolon separator, default type is string. Ex: firstName,age:numeric,createdate:timestamp
* @properties Enter a list of properties to generate. You can add the ORM type via colon separator, default type is string. Ex: firstName,age:numeric,createdate:timestamp
* @tests Generate the unit test BDD component
* @testsDirectory Your unit tests directory. Only used if tests is true
* @script Generate as script or not, defaults to true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Forget an embedded CFML server from persistent disk. Run command from the web root of the server, or use the short name.
* This command will remove all of the engine files for the server as well as all CF configuration as well. If you don't
* want to lose your settings, back them up first with the CFConfig tool.
* .
* {code:bash}
* server forget
Expand Down
8 changes: 0 additions & 8 deletions src/cfml/system/modules_app/system-commands/commands/cfml.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@ component{
// Print out the results
print.text( result );

// Try to do some "smart" debugging if the response was an error
// Todo, need to have a more explicit 'error' code that comes back
if( result contains 'error' ) {
print.yellowline( "Here is the last CFML function that was run" )
.line()
.line( functionText )
.line();
}
}

private function escapeArg( required string arg ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ component {
propertyFilePath = fileSystemUtil.resolvePath( propertyFilePath );

// Create and load property file object
propertyFile( propertyFilePath )
if( fileExists( propertyFilePath ) ){
var pf = propertyFile( propertyFilePath );
} else {
var pf = propertyFile();
}
pf
.set( propertyName, propertyValue )
.store();
.store( propertyFilePath );

print
.greenLine( 'Property set!' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ component {
testboxURL &= "&#thisOption#=#arguments[ thisOption ]#";
}
// Check runtime options now
else if( boxOptions.keyExists( thisOption ) ){
else if( boxOptions.keyExists( thisOption ) && len( boxOptions[ thisOption ] ) ){
testboxURL &= "&#thisOption#=#boxOptions[ thisOption ]#";
}
// Defaults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* {code}
*
* If you need more control over what tests run and their output, you can set additional options in your box.json
* which will be picked up automatically by "testbox run" whe it fires.
* which will be picked up automatically by "testbox run" when it fires.
*
* {code}
* package set testbox.verbose=false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/**
*
* Normalizes the indentation for a file or set of files
*
* {code:bash}
* indents **.cf* tabs
* {code}
*
* Change the number of spaces per tab
*
* {code:bash}
* indents **.cf* tabs 2
* {code}
*
* To skip the confirmation, use the --force flag.
*
* {code:bash}
* indents models/**.cfc --force
* {code}
*
* Print the file path of each file affected with the --verbose flag.
*
* {code:bash}
* indents includes/*.cfm --verbose
* {code}
*
* Exclude a list a globber patterns
*
* {code:bash}
* indents ** *.png,node_modules/
* {code}
*
* You can set global default parameters for this command to use like so:
*
* {code:bash}
* config set command.defaults.indents.force=true
* config set command.defaults.indents.verbose=true
* config set command.defaults.indents.exclude=.git/,*.png
* {code}
*
**/
component aliases="indents" {
property name="pathPatternMatcher" inject="provider:pathPatternMatcher@globber";

/**
* @files A file globbing pattern that matches one or more files
* @spacesOrTabs Convert to spaces or tabs
* @spaceTabCount The number of spaces per tab
* @exclude A list of globbing patterns to ignore
* @force Skip user confirmation of modiying files
* @verbose Output additional information about each file affected
*/
public function run(
required Globber files,
String spacesOrTabs = 'spaces',
Number spaceTabCount = 4,
String exclude = "",
Boolean force = false,
Boolean verbose = false
){
arguments.files = filterFiles( arguments.files, arguments.exclude );
var count = arguments.files.len();

if ( !arguments.force && !shell.confirm( "Confirm normalizing indents for #count# #count != 1 ? "files" : "file"#" ) ){
return;
}

for ( var file in arguments.files ){
normalizeIndents( file, arguments.verbose, arguments.spacesOrTabs, arguments.spaceTabCount );
}
}

private function normalizeIndents( filePath, verbose, spacesOrTabs, spaceTabCount ){
var trimLinesResult = fileNormalizeIndents( arguments.filePath, arguments.spacesOrTabs, arguments.spaceTabCount );

if ( trimLinesResult.fileChanged ){
if ( arguments.verbose ){
print.line( "Normalizing indents from " & arguments.filePath & "..." )
.toConsole();
}

// write new file
fileWrite( arguments.filePath, trimLinesResult.newData );
}
}

private function fileNormalizeIndents( filePath, spacesOrTabs, spaceTabCount ){
var fileData = fileRead( arguments.filePath );
var newData = javaCast( "string", fileData );

if ( arguments.spacesOrTabs == "tabs" ) {
var regex = "(?m)^(\s*)[ ]{" & arguments.spaceTabCount & "}(\s*)";

while ( reFind( regex, newData ) != 0 ) {
newData = newData.replaceAll( regex, "$1#chr(9)#$2" );
}

newData = newData.replaceAll( "(?m)^(\t*)[ ]+", "$1" )
} else {
var regex = "(?m)^(\s*)[\t]{1}(\s*)";

while ( reFind( regex, newData ) != 0 ) {
newData = newData.replaceAll( regex, "$1" & repeatString( " ", arguments.spaceTabCount ) & "$2" );
}
}

return { newData: newData, fileChanged: newData != fileData };
}

private function filterFiles( files, exclude ){
var filteredFiles = [];

arguments.files.apply( function( file ){
var fileInfo = getFileInfo( arguments.file );
// only process files
if ( fileInfo.type == "file" && !pathPatternMatcher.matchPatterns( listToArray( exclude ), arguments.file ) ){
filteredFiles.append( arguments.file );
}
} );

return filteredFiles;
}
}
Loading

0 comments on commit 8b4f197

Please sign in to comment.