Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdw429s committed Aug 18, 2021
2 parents ef4ac6d + 0593cfc commit 03713d9
Show file tree
Hide file tree
Showing 41 changed files with 529 additions and 213 deletions.
6 changes: 5 additions & 1 deletion build/brew-template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Commandbox < Formula
regex(/Download CommandBox v?(\d+(?:\.\d+)+)/i)
end

bottle do
sha256 cellar: :any_skip_relocation, all: "45b01d0263bf8842d6b060ed23202a77ab6b33d2a3c1c2a89be80eb4c50324ba"
end

depends_on "openjdk"

resource "apidocs" do
Expand All @@ -24,7 +28,7 @@ class Commandbox < Formula

def install
(libexec/"bin").install "box"
(bin/"box").write_env_script libexec/"bin/box", Language::Java.overridable_java_home_env
(bin/"box").write_env_script libexec/"bin/box", Language::Java.java_home_env("11")
doc.install resource("apidocs")
end

Expand Down
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.7.47
cfml.version=5.3.8.201
cfml.extensions=8D7FB0DF-08BB-1589-FE3975678F07DB17
cfml.loader.version=2.6.3
cfml.loader.version=2.6.5
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.11+9
launch4j.version=3.14
runwar.version=4.4.6
runwar.version=4.5.1
jline.version=3.19.0
jansi.version=2.3.2
jgit.version=5.11.0.202103091610-r
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="5.3.1"/>
<property name="commandbox.stableVersion" value="5.3.1"/>
<property name="commandbox.version" value="5.4.0"/>
<property name="commandbox.stableVersion" value="5.4.0"/>

<!-- Time Label -->
<tstamp prefix="start"/>
Expand Down
6 changes: 6 additions & 0 deletions src/cfml/system/Bootstrap.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ This file will stay running the entire time the shell is open
// flush console
shell.getReader().flush();
// If we installed a system module in a one-off command, we still need to nuke the wirebox metadata cache.
if( shell.getReloadshell() ) {
// Wipe out cached metadata on reload.
wirebox.getCacheBox().getCache( 'metadataCache' ).clearAll();
}
// "box" was called all by itself with no commands
} else {
Expand Down
25 changes: 8 additions & 17 deletions src/cfml/system/Shell.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -799,18 +799,6 @@ component accessors="true" singleton {
printError( { message : e.message, detail: e.detail } );
}
// This type of error means the user hit Ctrl-C, during a readLine() call. Duck out and move along.
} catch ( UserInterruptException var e) {
// If this is a nested command, pass the exception along to unwind the entire stack.
if( !initialCommand ) {
rethrow;
} else {

ConsolePainter.forceStop();
variables.reader.getTerminal().writer().flush();
variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().print( variables.print.boldRedLine( 'CANCELLED' ) );
}

} catch (any e) {
// If this is a nested command, pass the exception along to unwind the entire stack.
if( !initialCommand ) {
Expand All @@ -823,9 +811,14 @@ component accessors="true" singleton {

ConsolePainter.forceStop();

variables.reader.getTerminal().writer().flush();
variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().print( variables.print.boldRedLine( 'CANCELLED' ) );
if( job.getActive() ) {
job.error( 'CANCELLED' );
} else {
job.reset();
variables.reader.getTerminal().writer().flush();
variables.reader.getTerminal().writer().println();
variables.reader.getTerminal().writer().print( variables.print.boldRedLine( 'CANCELLED' ) );
}
// Anything else is completely unexpected and means boom booms happened-- full stack please.
} else {

Expand All @@ -845,8 +838,6 @@ component accessors="true" singleton {
}
}

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

// We get to output the results ourselves
if( !isNull( result ) && !isSimpleValue( result ) ){
if( isArray( result ) ){
Expand Down
51 changes: 51 additions & 0 deletions src/cfml/system/endpoints/ForgeBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,57 @@ component accessors="true" implements="IEndpointInteractive" {
}
}

// validation goes here
var validationData = {
"slug": {
"maxLen": 255,
"required": true
},
"version": {
"maxLen": 25
},
"shortDescription": {
"maxLen": 200
},
"name": {
"maxLen": 255
},
"homepage": {
"maxLen": 500
},
"documentation": {
"maxLen": 255
},
"bugs": {
"maxLen": 255
},
"repository.URL": {
"maxLen": 500
}
};

var errors = [];
consoleLogger.info( "Start validation..." );
validationData.each( ( prop, validData ) => {
if( validData.keyExists( 'required' ) ) {
if( len( Evaluate( "boxJSON.#prop#" ) ) == 0 ) {
errors.append( "[#prop#] is required" );
}
}
if( validData.keyExists( 'maxLen' ) ) {
if( isDefined( "boxJSON.#prop#" ) && len( Evaluate( "boxJSON.#prop#" ) ) > validData[ "maxLen" ] ) {
errors.append( "[#prop#] must be #validData[ 'maxLen' ]# characters or shorter" );
}
}

} );

// validation message if errors show up
if( errors.len() > 0 ){
errors.append( "#chr(10)#Please fix the invalid data and try publishing again." );
throw( "There were validation errors in publishing...", "endpointException", errors.toList( chr(10) ) );
}

try {
consoleLogger.warn( "Sending package information to #getNamePrefixes()#, please wait..." );
if ( upload ) { consoleLogger.warn( "Uploading package zip to #getNamePrefixes()#..." ); }
Expand Down
46 changes: 36 additions & 10 deletions src/cfml/system/endpoints/Jar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ component accessors=true implements="IEndpoint" singleton {

function init() {
setNamePrefixes( 'jar' );
variables.defaultVersion = '0.0.0';
return this;
}

Expand Down Expand Up @@ -64,7 +65,7 @@ component accessors=true implements="IEndpoint" singleton {
var boxJSON = {
'name' : '#getDefaultName( package )#.jar',
'slug' : getDefaultName( package ),
'version' : '0.0.0',
'version' : guessVersionFromURL( package ),
'location' : 'jar:#package#',
'type' : 'jars'
};
Expand Down Expand Up @@ -98,16 +99,41 @@ component accessors=true implements="IEndpoint" singleton {
}

public function getUpdate( required string package, required string version, boolean verbose=false ) {
var result = {
// Jars with a semver in the name are considered to not have an update since we assume they are an exact version
isOutdated = !package
packageVersion = guessVersionFromURL( package );
// No version could be determined from package URL
if( packageVersion == defaultVersion ) {
return {
isOutdated = true,
version = 'unknown'
};
// Our package URL has a version and it's the same as what's installed
} else if( version == packageVersion ) {
return {
isOutdated = false,
version = packageVersion
};
// our package URL has a versiion and it's not what's installed
} else {
return {
isOutdated = true,
version = packageVersion
};
}
}

private function guessVersionFromURL( required string package ) {
var version = package;
if( version contains '/' ) {
var version = version
.reReplaceNoCase( '^([\w:]+)?//', '' )
.listRest( '/\' )
.reFindNoCase( '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ),
version = 'unknown'
};

return result;
.listRest( '/\' );
}
if( version.refindNoCase( '.*([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*' ) ) {
version = version.reReplaceNoCase( '.*([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*', '\1' );
} else {
version = defaultVersion;
}
return version;
}

}
2 changes: 1 addition & 1 deletion src/cfml/system/modules/globber/ModuleConfig.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
component {

this.name = "globber";
this.author = "";
this.webUrl = "https://github.com//globber";
Expand Down
8 changes: 4 additions & 4 deletions src/cfml/system/modules/globber/box.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name":"Globber",
"version":"3.0.4",
"version":"3.0.6",
"author":"Brad Wood",
"location":"Ortus-Solutions/globber#v3.0.4",
"location":"Ortus-Solutions/globber#v3.0.6",
"homepage":"https://github.com/Ortus-Solutions/globber/",
"documentation":"https://github.com/Ortus-Solutions/globber/",
"repository":{
"type":"Git",
"URL":"git@github.com:Ortus-Solutions/globber.git"
"URL":"https://github.com/Ortus-Solutions/globber"
},
"bugs":"https://github.com/Ortus-Solutions/globber/issues",
"slug":"globber",
Expand All @@ -32,4 +32,4 @@
"test",
"tests"
]
}
}
6 changes: 5 additions & 1 deletion src/cfml/system/modules/globber/models/Globber.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,11 @@ component accessors="true" {
sort=getSort(),
filter=optimizeFilter
).filter( ( path )=>{
var thisPath = path.directory & '/' & path.name & ( path.type == 'dir' ? '/' : '' );
if( path.directory.endsWith( '/' ) || path.directory.endsWith( '\' ) ) {
var thisPath = path.directory & path.name & ( path.type == 'dir' ? '/' : '' );
} else {
var thisPath = path.directory & '/' & path.name & ( path.type == 'dir' ? '/' : '' );
}
if( pathPatternMatcher.matchPattern( thisPattern, thisPath, true ) ) {
if( getExcludePatternArray().len() && pathPatternMatcher.matchPatterns( getExcludePatternArray(), thisPath, true ) ) {
return false;
Expand Down
20 changes: 11 additions & 9 deletions src/cfml/system/modules/globber/models/PathPatternMatcher.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ component accessors="true" singleton {
/**
* Match a single path to a single pattern. Returns true if the path matches the pattern, otherwise false.
* The "exact" param is because Globber has different use cases. For example, when used for things like ignore lists
* a pattern not preceded by a slash should match directories and files recursively, any level deep. But when used for a
* a pattern not preceded by a slash should match directories and files recursibley, any level deep. But when used for a
* directory listing, it's expected to use ** /pattern/ ** to match deep folder.
* A pattern like foo must also match the entire file or folder name, not a partial name unless explicitly passed as *foo, foo*, or *foo*
*
*
* @pattern The pattern to match against the path
* @path The file system path to test. Can be a file or directory. Directories MUST end with a trailing slash
* @exact True if the full path needs to match. False to match inside a path.
* @path The file system path to test. Can be a file or directory. Direcories MUST end with a trailing slash
* @exact True if the full path needs to match. False to match inside a path.
*/
boolean function matchPattern( required string pattern, required string path, boolean exact=false ) {
// Normalize slashes
// This will turn a Windows UNC path into //server, but it will at least be consistent across pattern and path
// This will turn a Windows UNC path into //server, but it will at least be consitent across pattern and path
arguments.pattern = replace( arguments.pattern, '\', '/', 'all' );
arguments.path = replace( arguments.path, '\', '/', 'all' );

Expand All @@ -67,6 +67,8 @@ component accessors="true" singleton {
regex = replace( regex, '+', '\+', 'all' );
regex = replace( regex, '{', '\{', 'all' );
regex = replace( regex, '}', '\}', 'all' );
regex = replace( regex, '[', '\[', 'all' );
regex = replace( regex, ']', '\]', 'all' );

// /**/ matches zero or more directories (at least one /)
regex = replace( regex, '/**/', '__zeroOrMoreDirs_', 'all' );
Expand Down Expand Up @@ -105,7 +107,7 @@ component accessors="true" singleton {
regex &= '.*';
} else {
// Pattern can be at end of string or a slash and the anything (needs to match a whole segment)
regex &= '($|/.*)';
regex &= '($|/.*)';
}
}

Expand All @@ -115,7 +117,7 @@ component accessors="true" singleton {
/**
* Match an array of patterns against a single path. Returns true if at least one pattern matches, otherwise false.
* @patterns.hint An array of patterns to match against the path
* @path.hint The file system path to test. Can be a file or directory. Directories MUST end with a trailing slash
* @path.hint The file system path to test. Can be a file or directory. Direcories MUST end with a trailing slash
*/
boolean function matchPatterns( required array patterns, required string path, boolean exact=false ){
var matched = false;
Expand All @@ -138,15 +140,15 @@ component accessors="true" singleton {
boolean function isExclusion( required string pattern ) {
return left( pattern, 1 ) == "!";
}

/*
* Turns all slashes in a path to forward slashes except for \\ in a Windows UNC network share
*/
function normalizeSlashes( string path ) {
if( path.left( 2 ) == '\\' ) {
return '\\' & path.replace( '\', '/', 'all' ).right( -2 );
} else {
return path.replace( '\', '/', 'all' );
return path.replace( '\', '/', 'all' );
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/cfml/system/modules/globber/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Inject the path pattern matcher service/Globber or get it from WireBox.

### Path Pattern Matcher

This service is a singleton that handles path matching but doesn't actually touch the file system.
This service is a singleton that handles path matching but doesn't actually touch the file system.

```
var pathPatternMatcher = wirebox.getInstance( 'PathPatternMatcher@globber' );
Expand Down Expand Up @@ -46,7 +46,7 @@ A question mark matches a single non-slash character

* `/h?t` matches `hat` but not `ham` or `h/t`

### Globber
### Globber

This transient represents a single globbing pattern and provide a fluent API to access the matching files. Unlike the PathPatternMatcher, which only handles comparisons of patterns, this model actually interacts with the file system to resolve a pattern to a list of real file system resources.

Expand All @@ -68,8 +68,8 @@ wirebox.getInstance( 'globber' )

#### Get data as query

You can get a query back instead of an array by adding `.asQuery()` to your DSL. The also affects the datatype you `apply()` closure runs against.
The query columns match what comes from the `directoryList()` function.
You can get a query back instead of an array by adding `.asQuery()` to your DSL. The also affects the datatype you `apply()` closure runs against.
The query columns match what comes from the `directoryList()` fucntion.
```
var qryResults = globber
.setPattern( baseDir & '/**' )
Expand Down
6 changes: 3 additions & 3 deletions src/cfml/system/modules/semver/ModuleConfig.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
component {

function configure() {

}

}
4 changes: 2 additions & 2 deletions src/cfml/system/modules/semver/box.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name":"Semantic Version",
"version":"1.2.4",
"version":"1.2.5",
"author":"Brad Wood",
"location":"Ortus-Solutions/semanticVersion#v1.2.4",
"location":"Ortus-Solutions/semanticVersion#v1.2.5",
"homepage":"https://github.com/Ortus-Solutions/semanticVersion/",
"documentation":"https://github.com/Ortus-Solutions/semanticVersion/",
"repository":{
Expand Down
Loading

0 comments on commit 03713d9

Please sign in to comment.