Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion commands/wheels/base.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
79 changes: 0 additions & 79 deletions commands/wheels/generate/.cfformat.json

This file was deleted.

15 changes: 9 additions & 6 deletions commands/wheels/generate/app.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -204,12 +207,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
Expand Down
116 changes: 63 additions & 53 deletions commands/wheels/generate/controller.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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#' );
}

}
}
4 changes: 3 additions & 1 deletion commands/wheels/generate/model.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
7 changes: 5 additions & 2 deletions templates/ActionContent.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// |ActionHint|

/**
* |ActionHint| Action
**/
function |Action|() {

}
}
23 changes: 23 additions & 0 deletions templates/ConfigReloadPasswordContent.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<cfscript>
/*
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
</cfscript>
3 changes: 3 additions & 0 deletions templates/ControllerContent.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
component extends="Controller" {

/**
* Controller config settings
**/
function config() {

}
Expand Down