From 416275cc5166c112fd6a090c23cc3caa92822643 Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 10 Feb 2022 11:16:15 -0800 Subject: [PATCH 1/8] remove the .cfformat from the repository --- commands/wheels/generate/.cfformat.json | 79 ------------------------- 1 file changed, 79 deletions(-) delete mode 100644 commands/wheels/generate/.cfformat.json diff --git a/commands/wheels/generate/.cfformat.json b/commands/wheels/generate/.cfformat.json deleted file mode 100644 index 12aac92..0000000 --- a/commands/wheels/generate/.cfformat.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "alignment.consecutive.assignments":true, - "alignment.consecutive.params":true, - "alignment.consecutive.properties":true, - "alignment.doc_comments":true, - "array.empty_padding":false, - "array.multiline.comma_dangle":false, - "array.multiline.element_count":4, - "array.multiline.leading_comma":false, - "array.multiline.leading_comma.padding":true, - "array.multiline.min_length":40, - "array.padding":true, - "binary_operators.newline_indent":true, - "binary_operators.padding":true, - "brackets.padding":false, - "comment.asterisks":"align", - "for_loop_semicolons.padding":true, - "function_anonymous.empty_padding":false, - "function_anonymous.group_to_block_spacing":"spaced", - "function_anonymous.multiline.comma_dangle":false, - "function_anonymous.multiline.element_count":4, - "function_anonymous.multiline.leading_comma":false, - "function_anonymous.multiline.leading_comma.padding":true, - "function_anonymous.multiline.min_length":40, - "function_anonymous.padding":false, - "function_anonymous.spacing_to_group":false, - "function_call.casing.builtin":"cfdocs", - "function_call.casing.userdefined":"camel", - "function_call.empty_padding":false, - "function_call.multiline.comma_dangle":false, - "function_call.multiline.element_count":4, - "function_call.multiline.leading_comma":false, - "function_call.multiline.leading_comma.padding":true, - "function_call.multiline.min_length":40, - "function_call.padding":true, - "function_declaration.empty_padding":true, - "function_declaration.group_to_block_spacing":"spaced", - "function_declaration.multiline.comma_dangle":false, - "function_declaration.multiline.element_count":4, - "function_declaration.multiline.leading_comma":false, - "function_declaration.multiline.leading_comma.padding":true, - "function_declaration.multiline.min_length":40, - "function_declaration.padding":true, - "function_declaration.spacing_to_group":false, - "indent_size":2, - "keywords.block_to_keyword_spacing":"spaced", - "keywords.empty_group_spacing":true, - "keywords.group_to_block_spacing":"spaced", - "keywords.padding_inside_group":true, - "keywords.spacing_to_block":"spaced", - "keywords.spacing_to_group":true, - "max_columns":120, - "metadata.key_value.padding":false, - "metadata.multiline.element_count":4, - "metadata.multiline.min_length":40, - "method_call.chain.multiline":3, - "newline":"os", - "param.key_value.padding":false, - "param.multiline.element_count":4, - "param.multiline.min_length":40, - "parentheses.padding":false, - "property.key_value.padding":false, - "property.multiline.element_count":4, - "property.multiline.min_length":40, - "strings.attributes.quote":"double", - "strings.convertNestedQuotes":true, - "strings.quote":"single", - "struct.empty_padding":false, - "struct.multiline.comma_dangle":false, - "struct.multiline.element_count":4, - "struct.multiline.leading_comma":false, - "struct.multiline.leading_comma.padding":true, - "struct.multiline.min_length":40, - "struct.padding":false, - "struct.quote_keys":false, - "struct.separator":": ", - "tab_indent":false, - "tags.lowercase":true -} \ No newline at end of file From 71e6605e9b9d21c8977396c148236be09e58e148 Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 10 Feb 2022 11:16:57 -0800 Subject: [PATCH 2/8] Modify the controller with some basic reformatting --- commands/wheels/generate/controller.cfc | 116 +++++++++++++----------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/commands/wheels/generate/controller.cfc b/commands/wheels/generate/controller.cfc index d564cbc..af24b47 100644 --- a/commands/wheels/generate/controller.cfc +++ b/commands/wheels/generate/controller.cfc @@ -13,65 +13,75 @@ * wheels generate controller user index,customaction * {code} **/ -component aliases='wheels g controller' extends="../base" { +component + aliases="wheels g controller" + extends="../base" +{ - /** - * @name.hint Name of the controller to create without the .cfc - * @actionList.hint optional list of actions, comma delimited - * @directory.hint if for some reason you don't have your controllers in /controllers/ - **/ - function run( - required string name, - string actionList="", - directory='controllers' - ){ - var obj = helpers.getNameVariants(arguments.name); - arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); + /** + * @name.hint Name of the controller to create without the .cfc + * @actionList.hint optional list of actions, comma delimited + * @directory.hint if for some reason you don't have your controllers in /controllers/ + **/ + function run( + required string name, + string actionList = '', + directory = 'controllers' + ) { + var obj = helpers.getNameVariants( arguments.name ); + arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); - print.line( "Creating Controller..." ).toConsole(); + print.line( 'Creating Controller...' ).toConsole(); - // Validate directory - if( !directoryExists( arguments.directory ) ) { - error( "[#arguments.directory#] can't be found. Are you running this from your site root?" ); - } + // Validate directory + if ( !directoryExists( arguments.directory ) ) { + error( '[#arguments.directory#] can''t be found. Are you running this from your site root?' ); + } - // If custom actions passed in as arguments, then use them, otherwise use CRUD - var actionContent = ""; + // If custom actions passed in as arguments, then use them, otherwise use CRUD + var actionContent = ''; - if( len( arguments.actionList ) && arguments.actionList != "CRUD" ){ - var allactions = ""; - var controllerContent = fileRead( helpers.getTemplate('/ControllerContent.txt') ); - // Loop Over actions to generate them - for( var thisAction in listToArray( arguments.actionList ) ) { - if( thisAction == 'init' ) { continue; } - allactions = allactions & $returnAction(thisAction); - print.yellowLine( "Generated Action: #thisAction#"); - } - actionContent = allactions; - } else { - // Do Crud: overrwrite whole controllerContent with CRUD template - controllerContent = fileRead( helpers.getTemplate('/CRUDContent.txt') ); - print.yellowLine( "Generating CRUD"); - } + if ( len( arguments.actionList ) && arguments.actionList != 'CRUD' ) { + var allactions = ''; + var controllerContent = fileRead( helpers.getTemplate( '/ControllerContent.txt' ) ); + // Loop Over actions to generate them + for ( var thisAction in listToArray( arguments.actionList ) ) { + if ( thisAction == 'init' ) { + continue; + } + allactions = allactions & $returnAction( thisAction ); + print.yellowLine( 'Generated Action: #thisAction#' ); + } + actionContent = allactions; + } else { + // Do Crud: overrwrite whole controllerContent with CRUD template + controllerContent = fileRead( helpers.getTemplate( '/CRUDContent.txt' ) ); + print.yellowLine( 'Generating CRUD' ); + } - // Inject actions in controller content - controllerContent = replaceNoCase( controllerContent, '|actions|', actionContent, 'all' ); - // Replace Object tokens - controllerContent=$replaceDefaultObjectNames(controllerContent, obj); + // Inject actions in controller content + controllerContent = replaceNoCase( + controllerContent, + '|actions|', + actionContent, + 'all' + ); + // Replace Object tokens + controllerContent = $replaceDefaultObjectNames( controllerContent, obj ); - var controllerName = obj.objectNamePluralC & ".cfc"; - var controllerPath = directory & "/" & controllerName; + var controllerName = obj.objectNamePluralC & '.cfc'; + var controllerPath = directory & '/' & controllerName; - if(fileExists(controllerPath)){ - if( confirm( '#controllerName# already exists in target directory. Do you want to overwrite? [y/n]' ) ) { - print.greenLine( 'Ok, going to overwrite...' ).toConsole(); - } else { - print.boldRedLine( 'Ok, aborting!' ); - return; - } - } - file action='write' file='#controllerPath#' mode ='777' output='#trim( controllerContent )#'; - print.line( 'Created #controllerName#' ); - } + if ( fileExists( controllerPath ) ) { + if ( confirm( '#controllerName# already exists in target directory. Do you want to overwrite? [y/n]' ) ) { + print.greenLine( 'Ok, going to overwrite...' ).toConsole(); + } else { + print.boldRedLine( 'Ok, aborting!' ); + return; + } + } + file action="write" file="#controllerPath#" mode="777" output="#trim( controllerContent )#"; + print.line( 'Created #controllerName#' ); + } -} \ No newline at end of file +} From b4f7b3299b5d2d2e9568f4d9816accc1d192fe6f Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 10 Feb 2022 11:17:13 -0800 Subject: [PATCH 3/8] change the comments to javadoc style --- templates/ActionContent.txt | 7 +++++-- templates/ControllerContent.txt | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/ActionContent.txt b/templates/ActionContent.txt index b557f15..aea1007 100644 --- a/templates/ActionContent.txt +++ b/templates/ActionContent.txt @@ -1,4 +1,7 @@ - // |ActionHint| + + /** + * |ActionHint| Action + **/ function |Action|() { - } + } \ No newline at end of file diff --git a/templates/ControllerContent.txt b/templates/ControllerContent.txt index 78b5744..bd7c0aa 100644 --- a/templates/ControllerContent.txt +++ b/templates/ControllerContent.txt @@ -1,5 +1,8 @@ component extends="Controller" { + /** + * Controller config settings + **/ function config() { } From a39466dac162b8a7e199966599935fa62c70b817 Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Fri, 11 Feb 2022 10:23:08 -0800 Subject: [PATCH 4/8] modify the token for the base package --- commands/wheels/generate/app.cfc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/wheels/generate/app.cfc b/commands/wheels/generate/app.cfc index 8d197b0..e4c495f 100644 --- a/commands/wheels/generate/app.cfc +++ b/commands/wheels/generate/app.cfc @@ -204,12 +204,12 @@ component aliases="wheels g app" extends="../base" { // Remove the cfwheels-base from the dependencies command( 'tokenReplace' ) - .params( path = 'box.json', token = '"cfwheels-base":"^2.2"', replacement = '' ) + .params( path = 'box.json', token = '"cfwheels-base":"^2.2",', replacement = '' ) .run(); // Remove the cfwheels-base from the install paths command( 'tokenReplace' ) - .params( path = 'box.json', token = '"cfwheels-base":"base/"', replacement = '' ) + .params( path = 'box.json', token = '"cfwheels-base":"base/",', replacement = '' ) .run(); // Add the H2 Lucee extension to the dependencies From a85e327d93035b2507253241e5d51b09b8710286 Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 17 Feb 2022 13:06:02 -0800 Subject: [PATCH 5/8] set server base url --- commands/wheels/base.cfc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commands/wheels/base.cfc b/commands/wheels/base.cfc index d6a2798..04efe07 100644 --- a/commands/wheels/base.cfc +++ b/commands/wheels/base.cfc @@ -226,7 +226,7 @@ component excludeFromHelp=true { // Get information about the currently running server so we can send commmands function $getServerInfo(){ - var serverDetails = serverService.resolveServerDetails( serverProps={ name=listLast( getCWD(), '/\' ) } ); + var serverDetails = serverService.resolveServerDetails( serverProps={ webroot=getCWD() } ); local.host = serverDetails.serverInfo.host; local.port = serverDetails.serverInfo.port; local.serverURL = "http://" & local.host & ":" & local.port; @@ -250,9 +250,11 @@ component excludeFromHelp=true { loc = new Http( url=targetURL ).send().getPrefix(); print.line("Sending: " & targetURL); + if(isJson(loc.filecontent)){ loc.result=deserializeJSON(loc.filecontent); if(structKeyexists(loc.result, "success") && loc.result.success){ + print.line("Call to bridge was successful."); return loc.result; //if(structKeyExists(loc.result, "MESSAGE")){ // return loc.result.message; From 555c8e54ddaa9542985c83489bca7a980ce238a8 Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 17 Feb 2022 13:06:50 -0800 Subject: [PATCH 6/8] update paths in H2 db creation --- commands/wheels/generate/app.cfc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/commands/wheels/generate/app.cfc b/commands/wheels/generate/app.cfc index e4c495f..6385cbc 100644 --- a/commands/wheels/generate/app.cfc +++ b/commands/wheels/generate/app.cfc @@ -94,6 +94,8 @@ component aliases="wheels g app" extends="../base" { } } + print.greenBoldLine( 'Currently working in #getCWD()#'); + // If the template is one of our "shortcut" names if ( variables.templateMap.keyExists( arguments.template ) ) { // Replace it with the actual ForgeBox slug name. @@ -164,17 +166,18 @@ component aliases="wheels g app" extends="../base" { var datadirectory = fileSystemUtil.resolvePath( 'db/h2/' ); if ( !directoryExists( datadirectory ) ) { - print.greenline( 'Creating /db/h2/ path...' ).toConsole(); + print.greenline( 'Creating #arguments.directory# path...' ).toConsole(); directoryCreate( datadirectory ); } print.greenline( 'Adding Datasource to app.cfm...' ).toConsole(); var datasourceConfig = 'this.datasources[''#arguments.datasourceName#''] = { class: ''org.h2.Driver'' - , connectionString: ''jdbc:h2:file:#expandPath( '/db/h2/' )##arguments.datasourceName#;MODE=MySQL'' - , username = ''sa'' + , connectionString: ''jdbc:h2:file:#datadirectory##arguments.datasourceName#;MODE=MySQL'' + , username = ''sa'' }; - // CLI-Appends-Here'; + // CLI-Appends-Here'; + print.yellowline( datasourceConfig ).toConsole(); command( 'tokenReplace' ) .params( path = 'config/app.cfm', token = '// CLI-Appends-Here', replacement = datasourceConfig ) .run(); From 5305d091ce1ce875a3ed9214904d009b30bf5fdc Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 17 Feb 2022 13:07:36 -0800 Subject: [PATCH 7/8] incremental changes --- commands/wheels/generate/model.cfc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commands/wheels/generate/model.cfc b/commands/wheels/generate/model.cfc index a64d5a2..c6ae789 100644 --- a/commands/wheels/generate/model.cfc +++ b/commands/wheels/generate/model.cfc @@ -18,14 +18,16 @@ component aliases='wheels g model' extends="../base" { /** * @name.hint Name of the model to create without the .cfc: assumes singluar can be foo/foo * @fields.hint Comma Delimited list of fields with type after semicolon + * @db.hint Boolean attribute specifying if the database table should be generated as well **/ function run( required string name, boolean db=true ){ - var obj = helpers.getNameVariants(arguments.name); + var obj = helpers.getNameVariants(arguments.name); var directory = fileSystemUtil.resolvePath("models"); + //TODO: Refactor into a function that tries to get the app name from the server.json file var appName = listLast( getCWD(), '/\' ); if(db){ From 8a13bd73eaa3c132c5b288d67bcbe852043cd9c2 Mon Sep 17 00:00:00 2001 From: Peter Amiri Date: Thu, 17 Feb 2022 13:08:13 -0800 Subject: [PATCH 8/8] update content files --- ...tent.txt => ConfigDataSourceH2Content.txt} | 0 templates/ConfigReloadPasswordContent.txt | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+) rename templates/{ConfigSettingsContent.txt => ConfigDataSourceH2Content.txt} (100%) create mode 100644 templates/ConfigReloadPasswordContent.txt diff --git a/templates/ConfigSettingsContent.txt b/templates/ConfigDataSourceH2Content.txt similarity index 100% rename from templates/ConfigSettingsContent.txt rename to templates/ConfigDataSourceH2Content.txt diff --git a/templates/ConfigReloadPasswordContent.txt b/templates/ConfigReloadPasswordContent.txt new file mode 100644 index 0000000..09f4165 --- /dev/null +++ b/templates/ConfigReloadPasswordContent.txt @@ -0,0 +1,23 @@ + + /* + If you leave these settings commented out, CFWheels will set the data source name to the same name as the folder the application resides in. + */ + + // set(dataSourceName=""); + // set(dataSourceUserName=""); + // set(dataSourcePassword=""); + + /* + If you leave this setting commented out, CFWheels will try to determine the URL rewrite capabilities automatically. + The "URLRewriting" setting can bet set to "on", "partial" or "off". + To run with "partial" rewriting, the "cgi.path_info" variable needs to be supported by the web server. + To run with rewriting set to "on", you need to apply the necessary rewrite rules on the web server first. + */ + + // Added via CFWheels CLI + set(dataSourceName="|datasourceName|"); + set(URLRewriting="On"); + // Reload your application with ?reload=true&password=|reloadPassword| + set(reloadPassword="|reloadPassword|"); + // CLI-Appends-Here +