-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/development'
- Loading branch information
Showing
21 changed files
with
402 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ] ); | ||
} | ||
|
||
/** | ||
|
@@ -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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/cfml/system/modules_app/server-commands/commands/server/forget.cfc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/cfml/system/modules_app/utils-commands/commands/utils/normalize-indents.cfc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.