Skip to content

Commit

Permalink
Merge branch 'development' of github.com:ColdBox/coldbox-cli into dev…
Browse files Browse the repository at this point in the history
…elopment
  • Loading branch information
lmajano committed Dec 14, 2023
2 parents 6ce4127 + 01b8538 commit 1bd904e
Show file tree
Hide file tree
Showing 21 changed files with 299 additions and 116 deletions.
26 changes: 21 additions & 5 deletions build/Build.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ component {
];

// Cleanup + Init Build Directories
[ variables.buildDir, variables.artifactsDir ].each( function( item ){
[
variables.buildDir,
variables.artifactsDir
].each( function( item ){
if ( directoryExists( item ) ) {
directoryDelete( item, true );
}
Expand Down Expand Up @@ -132,11 +135,18 @@ component {

// Project Build Dir
variables.projectBuildDir = variables.buildDir & "/#projectName#";
directoryCreate( variables.projectBuildDir, true, true );
directoryCreate(
variables.projectBuildDir,
true,
true
);

// Copy source
print.blueLine( "Copying source to build folder..." ).toConsole();
copy( variables.cwd, variables.projectBuildDir );
copy(
variables.cwd,
variables.projectBuildDir
);

// Create build ID
fileWrite(
Expand Down Expand Up @@ -175,7 +185,10 @@ component {
);

// Copy box.json for convenience
fileCopy( "#variables.projectBuildDir#/box.json", variables.exportsDir );
fileCopy(
"#variables.projectBuildDir#/box.json",
variables.exportsDir
);
}

/**
Expand Down Expand Up @@ -285,7 +298,10 @@ component {
/**
* Ensure the export directory exists at artifacts/NAME/VERSION/
*/
private function ensureExportDir( required projectName, version = "1.0.0" ){
private function ensureExportDir(
required projectName,
version = "1.0.0"
){
if ( structKeyExists( variables, "exportsDir" ) && directoryExists( variables.exportsDir ) ) {
return;
}
Expand Down
4 changes: 1 addition & 3 deletions commands/coldbox/create/app-wizard.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ component extends="app" aliases="" {
print.boldgreenline( ".env is a module that creates a local variables that can be" );
print.greenline( "used in many places such as .cfconfig.json, box.json, Coldbox.cfc, etc." );
print.greenline( "You will see these used in the template in some of the files above" );
print.greenline(
"ex. ""${DB_DATABASE}"" or getSystemSetting( ""APPNAME"", ""Your app name here"" )"
);
print.greenline( "ex. ""${DB_DATABASE}"" or getSystemSetting( ""APPNAME"", ""Your app name here"" )" );
print.greenline( "More info at https://github.com/commandbox-modules/commandbox-dotenv" );
print.boldgreenline(
"----------------------------------------------------------------------------------------"
Expand Down
4 changes: 1 addition & 3 deletions commands/coldbox/create/bdd.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ component {
directory = "tests/specs"
){
// proxy to testbox
runCommand(
"testbox create bdd name=#arguments.name# directory=#arguments.directory# open=#arguments.open#"
);
runCommand( "testbox create bdd name=#arguments.name# directory=#arguments.directory# open=#arguments.open#" );
}

}
34 changes: 24 additions & 10 deletions commands/coldbox/create/handler.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,18 @@ component aliases="coldbox create controller" extends="coldbox-cli.models.BaseCo
"all"
);
} else {
handlerContent = replaceNoCase( handlerContent, "|EventActions|", "", "all" );
handlerTestContent = replaceNoCase( handlerTestContent, "|TestCases|", "", "all" );
handlerContent = replaceNoCase(
handlerContent,
"|EventActions|",
"",
"all"
);
handlerTestContent = replaceNoCase(
handlerTestContent,
"|TestCases|",
"",
"all"
);
}

// Create dir if it doesn't exist
Expand Down Expand Up @@ -158,7 +168,11 @@ component aliases="coldbox create controller" extends="coldbox-cli.models.BaseCo
if ( arguments.integrationTests ) {
var testPath = resolvePath( "#arguments.testsDirectory#/#arguments.name#Test.cfc" );
// Create dir if it doesn't exist
directoryCreate( getDirectoryFromPath( testPath ), true, true );
directoryCreate(
getDirectoryFromPath( testPath ),
true,
true
);
// Create the tests
file action="write" file="#testPath#" mode="777" output="#handlerTestContent#";
printInfo( "Created Integration Spec [#testPath#]" );
Expand Down Expand Up @@ -198,9 +212,7 @@ component aliases="coldbox create controller" extends="coldbox-cli.models.BaseCo
var actionContent = fileRead(
arguments.rest ? "#variables.settings.templatesPath#/RestActionContent.txt" : "#variables.settings.templatesPath#/ActionContent.txt"
);
var handlerTestCaseContent = fileRead(
"#variables.settings.templatesPath#/testing/HandlerBDDCaseContent.txt"
);
var handlerTestCaseContent = fileRead( "#variables.settings.templatesPath#/testing/HandlerBDDCaseContent.txt" );

// Loop Over actions generating their functions
for ( var thisAction in listToArray( arguments.actions ) ) {
Expand All @@ -213,10 +225,12 @@ component aliases="coldbox create controller" extends="coldbox-cli.models.BaseCo
"all"
);
// Action Replacement
results.actions = replaceNoCase( results.actions, "|action|", thisAction, "all" ) & repeatString(
variables.cr,
1
);
results.actions = replaceNoCase(
results.actions,
"|action|",
thisAction,
"all"
) & repeatString( variables.cr, 1 );

// Are we creating views? But only if we are NOT in rest mode
if ( arguments.views && !arguments.rest && !listFindNoCase( "create,update,delete", thisAction ) ) {
Expand Down
4 changes: 1 addition & 3 deletions commands/coldbox/create/help.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ component excludeFromHelp=true {
.blue( "as you plan your application. Most commands create a single file, but """ )
.boldblue( "coldbox create app" )
.blueLine( """" )
.blueLine(
"will generate an entire, working application into an empty folder for you. Type help before"
)
.blueLine( "will generate an entire, working application into an empty folder for you. Type help before" )
.blueLine( "any command name to get additional information on how to call that specific command." )
.line()
.line();
Expand Down
7 changes: 6 additions & 1 deletion commands/coldbox/create/integration-test.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ component extends="coldbox-cli.models.BaseCommand" {
"all"
);
} else {
handlerTestContent = replaceNoCase( handlerTestContent, "|TestCases|", "", "all" );
handlerTestContent = replaceNoCase(
handlerTestContent,
"|TestCases|",
"",
"all"
);
}

var integrationTestPath = "#arguments.directory#/#arguments.handler#Test.cfc";
Expand Down
14 changes: 7 additions & 7 deletions commands/coldbox/create/interceptor-test.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ component extends="coldbox-cli.models.BaseCommand" {
}

// Read in Template
var interceptorTestContent = fileRead(
"#variables.settings.templatesPath#/testing/InterceptorBDDContent.txt"
);
var interceptorTestCase = fileRead(
"#variables.settings.templatesPath#/testing/InterceptorBDDCaseContent.txt"
);
var interceptorTestContent = fileRead( "#variables.settings.templatesPath#/testing/InterceptorBDDContent.txt" );
var interceptorTestCase = fileRead( "#variables.settings.templatesPath#/testing/InterceptorBDDCaseContent.txt" );

// Start Replacing
interceptorTestContent = replaceNoCase(
Expand Down Expand Up @@ -79,7 +75,11 @@ component extends="coldbox-cli.models.BaseCommand" {
// Write it out.
var testPath = "#arguments.testsDirectory#/#listLast( arguments.path, "." )#Test.cfc";
// Create dir if it doesn't exist
directoryCreate( getDirectoryFromPath( testPath ), true, true );
directoryCreate(
getDirectoryFromPath( testPath ),
true,
true
);

// Confirm it
if (
Expand Down
14 changes: 7 additions & 7 deletions commands/coldbox/create/interceptor.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ component extends="coldbox-cli.models.BaseCommand" {
// Read in Template
var interceptorContent = fileRead( "#variables.settings.templatesPath#/InterceptorContent.txt" );
var interceptorMethod = fileRead( "#variables.settings.templatesPath#/InterceptorMethod.txt" );
var interceptorTestContent = fileRead(
"#variables.settings.templatesPath#/testing/InterceptorBDDContent.txt"
);
var interceptorTestCase = fileRead(
"#variables.settings.templatesPath#/testing/InterceptorBDDCaseContent.txt"
);
var interceptorTestContent = fileRead( "#variables.settings.templatesPath#/testing/InterceptorBDDContent.txt" );
var interceptorTestCase = fileRead( "#variables.settings.templatesPath#/testing/InterceptorBDDCaseContent.txt" );

// Start Replacing
interceptorContent = replaceNoCase(
Expand Down Expand Up @@ -149,7 +145,11 @@ component extends="coldbox-cli.models.BaseCommand" {
if ( tests ) {
var testPath = "#TestsDirectory#/#arguments.name#Test.cfc";
// Create dir if it doesn't exist
directoryCreate( getDirectoryFromPath( testPath ), true, true );
directoryCreate(
getDirectoryFromPath( testPath ),
true,
true
);
// Create the tests
file action="write" file="#testPath#" mode="777" output="#interceptorTestContent#";
printInfo( "Created #testPath#" );
Expand Down
17 changes: 12 additions & 5 deletions commands/coldbox/create/model-test.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ component extends="coldbox-cli.models.BaseCommand" {

// Read in Template
var modelTestContent = fileRead( "#variables.settings.templatesPath#/testing/ModelBDDContent.txt" );
var modelTestMethodContent = fileRead(
"#variables.settings.templatesPath#/testing/ModelBDDMethodContent.txt"
);
var modelTestMethodContent = fileRead( "#variables.settings.templatesPath#/testing/ModelBDDMethodContent.txt" );

// Basic replacements
modelTestContent = replaceNoCase(
Expand Down Expand Up @@ -90,12 +88,21 @@ component extends="coldbox-cli.models.BaseCommand" {
"all"
);
} else {
modelTestContent = replaceNoCase( modelTestContent, "|TestCases|", "", "all" );
modelTestContent = replaceNoCase(
modelTestContent,
"|TestCases|",
"",
"all"
);
}

var testPath = "#arguments.TestsDirectory#/#listLast( arguments.path, "." )#Test.cfc";
// Create dir if it doesn't exist
directoryCreate( getDirectoryFromPath( testPath ), true, true );
directoryCreate(
getDirectoryFromPath( testPath ),
true,
true
);

// Confirm it
if (
Expand Down
57 changes: 46 additions & 11 deletions commands/coldbox/create/model.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,18 @@ component extends="coldbox-cli.models.BaseCommand" {
error( "Cannot scaffold a model with an empty name." );
}
// Validate persistence
if ( !listFindNoCase( variables.validPersistences, arguments.persistence ) ) {
if (
!listFindNoCase(
variables.validPersistences,
arguments.persistence
)
) {
error(
"The persistence value [#arguments.persistence#] is invalid. Valid values are [#listChangeDelims( variables.validPersistences, ", ", "," )#]"
"The persistence value [#arguments.persistence#] is invalid. Valid values are [#listChangeDelims(
variables.validPersistences,
", ",
","
)#]"
);
}
// Exit the command if something above failed
Expand All @@ -118,9 +127,7 @@ component extends="coldbox-cli.models.BaseCommand" {
var modelContent = fileRead( "#variables.settings.templatesPath#/ModelContent.txt" );
var modelMethodContent = fileRead( "#variables.settings.templatesPath#/ModelMethodContent.txt" );
var modelTestContent = fileRead( "#variables.settings.templatesPath#/testing/ModelBDDContent.txt" );
var modelTestMethodContent = fileRead(
"#variables.settings.templatesPath#/testing/ModelBDDMethodContent.txt"
);
var modelTestMethodContent = fileRead( "#variables.settings.templatesPath#/testing/ModelBDDMethodContent.txt" );

// Basic replacements
modelContent = replaceNoCase(
Expand Down Expand Up @@ -163,7 +170,12 @@ component extends="coldbox-cli.models.BaseCommand" {
// Persistence
switch ( Persistence ) {
case "Transient":
modelContent = replaceNoCase( modelContent, "|modelPersistence|", "", "all" );
modelContent = replaceNoCase(
modelContent,
"|modelPersistence|",
"",
"all"
);
break;
case "Singleton":
modelContent = replaceNoCase(
Expand All @@ -183,7 +195,12 @@ component extends="coldbox-cli.models.BaseCommand" {
"all"
);
} else {
modelContent = replaceNoCase( modelContent, "|accessors|", "", "all" );
modelContent = replaceNoCase(
modelContent,
"|accessors|",
"",
"all"
);
}

// Generate Model Properties
Expand Down Expand Up @@ -240,7 +257,12 @@ component extends="coldbox-cli.models.BaseCommand" {
}

// final replacement
modelContent = replaceNoCase( modelContent, "|methods|", allMethods, "all" );
modelContent = replaceNoCase(
modelContent,
"|methods|",
allMethods,
"all"
);
modelTestContent = replaceNoCase(
modelTestContent,
"|TestCases|",
Expand All @@ -249,13 +271,22 @@ component extends="coldbox-cli.models.BaseCommand" {
);
} else {
modelContent = replaceNoCase( modelContent, "|methods|", "", "all" );
modelTestContent = replaceNoCase( modelTestContent, "|TestCases|", "", "all" );
modelTestContent = replaceNoCase(
modelTestContent,
"|TestCases|",
"",
"all"
);
}

// Write out the model
var modelPath = "#arguments.directory#/#arguments.name#.cfc";
// Create dir if it doesn't exist
directoryCreate( getDirectoryFromPath( modelPath ), true, true );
directoryCreate(
getDirectoryFromPath( modelPath ),
true,
true
);

// Prompt for override
if (
Expand Down Expand Up @@ -324,7 +355,11 @@ component extends="coldbox-cli.models.BaseCommand" {
"all"
);
// Create dir if it doesn't exist
directoryCreate( getDirectoryFromPath( seederPath ), true, true );
directoryCreate(
getDirectoryFromPath( seederPath ),
true,
true
);
// Create the migration
file action="write" file="#seederPath#" mode="777" output="#seedContent#";
// open file
Expand Down
Loading

0 comments on commit 1bd904e

Please sign in to comment.