Skip to content

Commit a49fa64

Browse files
authored
Merge pull request #45 from cfwheels/upgrade_box
Incorporation with Updated CFWheels DS and Default Templates
2 parents 1ee67c0 + e8015f5 commit a49fa64

File tree

13 files changed

+64
-39
lines changed

13 files changed

+64
-39
lines changed

box.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name":"CFWheels CLI Commands",
3-
"version":"1.1.0",
3+
"version":"3.0.0",
44
"author":"Tom King, Peter Amiri",
5-
"location":"cfwheels/cfwheels-cli#v1.1.0",
5+
"location":"cfwheels/cfwheels-cli#v3.0.0",
66
"directory":"",
77
"createPackageDirectory":true,
88
"packageDirectory":"cfwheels-cli",

commands/wheels/base.cfc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ component excludeFromHelp=true {
1818
// we could also test for the existence of /wheels/dbmigrate, but that only gives us the major version.
1919
string function $getWheelsVersion(){
2020
// First, look for a wheels folder..
21-
if(!directoryExists( fileSystemUtil.resolvePath("wheels") ) ){
21+
if(!directoryExists( fileSystemUtil.resolvePath("vendor/wheels") ) ){
2222
error("We're currently looking in #getCWD()#, but can't find a /wheels/ folder?");
2323
}
24-
if(fileExists(fileSystemUtil.resolvePath("wheels/box.json"))){
25-
var output = command( 'cd wheels' ).run( returnOutput=true );
24+
if(fileExists(fileSystemUtil.resolvePath("vendor/wheels/box.json"))){
25+
var output = command( 'cd vendor\wheels' ).run( returnOutput=true );
2626
local.boxJSON = packageService.readPackageDescriptorRaw( getCWD() );
2727
var output = command( 'cd ../' ).run( returnOutput=true );
2828
return local.boxJSON.version;
29-
} else if(fileExists(fileSystemUtil.resolvePath("wheels/events/onapplicationstart.cfm"))) {
30-
var output = command( 'cd wheels' ).run( returnOutput=true );
31-
local.target=fileSystemUtil.resolvePath("events/onapplicationstart.cfm");
29+
} else if(fileExists(fileSystemUtil.resolvePath("vendor/wheels/events/onapplicationstart.cfm"))) {
30+
var output = command( 'cd vendor\wheels' ).run( returnOutput=true );
31+
local.target=fileSystemUtil.resolvePath("app/events/onapplicationstart.cfm");
3232
local.content=fileRead(local.target);
3333
local.content=listFirst(mid(local.content, (find('application.$wheels.version',local.content)+31),20),'"');
3434
var output = command( 'cd ../' ).run( returnOutput=true );
@@ -83,10 +83,10 @@ component excludeFromHelp=true {
8383
// Inject CLI content into template
8484
function $injectIntoView(required struct objectNames, required string property, required string type, string action="input"){
8585
if(arguments.action EQ "input"){
86-
local.target=fileSystemUtil.resolvePath("views/#objectNames.objectNamePlural#/_form.cfm");
86+
local.target=fileSystemUtil.resolvePath("app/views/#objectNames.objectNamePlural#/_form.cfm");
8787
local.inject=$generateFormField(objectname=objectNames.objectNameSingular, property=arguments.property, type=arguments.type);
8888
} else if(arguments.action EQ "output"){
89-
local.target=fileSystemUtil.resolvePath("views/#objectNames.objectNamePlural#/show.cfm");
89+
local.target=fileSystemUtil.resolvePath("app/views/#objectNames.objectNamePlural#/show.cfm");
9090
local.inject=$generateOutputField(objectname=objectNames.objectNameSingular, property=arguments.property, type=arguments.type);
9191
}
9292
local.content=fileRead(local.target);
@@ -101,7 +101,7 @@ component excludeFromHelp=true {
101101

102102
// Inject CLI content into index template
103103
function $injectIntoIndex(required struct objectNames, required string property, required string type){
104-
local.target=fileSystemUtil.resolvePath("views/#objectNames.objectNamePlural#/index.cfm");
104+
local.target=fileSystemUtil.resolvePath("app/views/#objectNames.objectNamePlural#/index.cfm");
105105
local.thead=" <th>#helpers.capitalize(arguments.property)#</th>";
106106
local.tbody=" <td>" & cr & " ~[~#arguments.property#~]~" & cr & " </td>";
107107

@@ -208,7 +208,7 @@ component excludeFromHelp=true {
208208
}
209209

210210
// Wheels folder in expected place? (just a good check to see if the user has actually installed wheels...)
211-
var wheelsFolder=fileSystemUtil.resolvePath("wheels");
211+
var wheelsFolder=fileSystemUtil.resolvePath("vendor/wheels");
212212
if(!directoryExists(wheelsFolder)){
213213
error("We can't find your wheels folder. Check you have installed CFWheels, and you're running this from the site root: If you've not started an app yet, try wheels new myApp");
214214
}
@@ -223,12 +223,12 @@ component excludeFromHelp=true {
223223
// Wheels 2.x has dbmigrate + dbmigratebridge equivalents in core
224224
if($isWheelsVersion(1, "major")){
225225

226-
var DBMigratePluginLocation=fileSystemUtil.resolvePath("plugins/dbmigrate");
226+
var DBMigratePluginLocation=fileSystemUtil.resolvePath("app/plugins/dbmigrate");
227227
if(!directoryExists(DBMigratePluginLocation)){
228228
error("We can't find your plugins/dbmigrate folder? Please check the plugin is successfully installed; if you've not started the server using server start for the first time, this folder may not be created yet.");
229229
}
230230

231-
var DBMigrateBridgePluginLocation=fileSystemUtil.resolvePath("plugins/dbmigratebridge");
231+
var DBMigrateBridgePluginLocation=fileSystemUtil.resolvePath("app/plugins/dbmigratebridge");
232232
if(!directoryExists(DBMigrateBridgePluginLocation)){
233233
error("We can't find your plugins/dbmigratebridge folder? Please check the plugin is successfully installed; if you've not started the server using server start for the first time, this folder may not be created yet.");
234234
}
@@ -249,7 +249,7 @@ component excludeFromHelp=true {
249249
string function $getBridgeURL() {
250250
var serverInfo=$getServerInfo();
251251
var geturl=serverInfo.serverUrl;
252-
getURL &= "/rewrite.cfm?controller=wheels&action=wheels&view=cli";
252+
getURL &= "/public/rewrite.cfm?controller=wheels&action=wheels&view=cli";
253253
return geturl;
254254
}
255255

commands/wheels/destroy.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ component aliases='wheels d' extends="base" {
1414
function run(required string name) {
1515

1616
var obj = helpers.getNameVariants(arguments.name);
17-
var modelFile = fileSystemUtil.resolvePath("models/#obj.objectNameSingularC#.cfc");
18-
var controllerFile = fileSystemUtil.resolvePath("controllers/#obj.objectNamePluralC#.cfc");
19-
var viewFolder = fileSystemUtil.resolvePath("views/#obj.objectNamePlural#/");
17+
var modelFile = fileSystemUtil.resolvePath("app/models/#obj.objectNameSingularC#.cfc");
18+
var controllerFile = fileSystemUtil.resolvePath("app/controllers/#obj.objectNamePluralC#.cfc");
19+
var viewFolder = fileSystemUtil.resolvePath("app/views/#obj.objectNamePlural#/");
2020
var testmodelFile = fileSystemUtil.resolvePath("tests/models/#obj.objectNameSingularC#.cfc");
2121
var testcontrollerFile = fileSystemUtil.resolvePath("tests/controllers/#obj.objectNamePluralC#.cfc");
2222
var testviewFolder = fileSystemUtil.resolvePath("tests/views/#obj.objectNamePlural#/");
23-
var routeFile = fileSystemUtil.resolvePath("config/routes.cfm");
23+
var routeFile = fileSystemUtil.resolvePath("app/config/routes.cfm");
2424
var resourceName = '.resources("' & obj.objectNamePlural & '")';
2525

2626
print.redBoldLine("================================================")

commands/wheels/generate/app.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ component aliases="wheels g app" extends="../base" {
140140

141141
// Setting Application Name
142142
print.greenBoldLine( 'Setting application name...' ).toConsole();
143-
command( 'tokenReplace' ).params( path = 'config/app.cfm', token = '|appName|', replacement = arguments.name ).run();
143+
command( 'tokenReplace' ).params( path = 'app/config/app.cfm', token = '|appName|', replacement = arguments.name ).run();
144144
command( 'tokenReplace' ).params( path = 'server.json', token = '|appName|', replacement = arguments.name ).run();
145145

146146
// Setting Reload Password
147147
print.greenBoldLine( 'Setting reload password...' ).toConsole();
148148
command( 'tokenReplace' )
149-
.params( path = 'config/settings.cfm', token = '|reloadPassword|', replacement = arguments.reloadPassword )
149+
.params( path = 'app/config/settings.cfm', token = '|reloadPassword|', replacement = arguments.reloadPassword )
150150
.run();
151151

152152
// Setting Datasource Name
153153
print.greenBoldLine( 'Setting datasource name...' ).toConsole();
154154
command( 'tokenReplace' )
155-
.params( path = 'config/settings.cfm', token = '|datasourceName|', replacement = arguments.datasourceName )
155+
.params( path = 'app/config/settings.cfm', token = '|datasourceName|', replacement = arguments.datasourceName )
156156
.run();
157157

158158
// Setting cfml Engine Name
@@ -183,7 +183,7 @@ component aliases="wheels g app" extends="../base" {
183183
// CLI-Appends-Here';
184184
print.yellowline( datasourceConfig ).toConsole();
185185
command( 'tokenReplace' )
186-
.params( path = 'config/app.cfm', token = '// CLI-Appends-Here', replacement = datasourceConfig )
186+
.params( path = 'app/config/app.cfm', token = '// CLI-Appends-Here', replacement = datasourceConfig )
187187
.run();
188188
print.greenline( '...Finished Adding Datasource to app.cfm.' ).toConsole();
189189
}

commands/wheels/generate/controller.cfc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ component
2626
function run(
2727
required string name,
2828
string actionList = '',
29-
directory = 'controllers'
29+
directory = 'app/controllers'
3030
) {
3131
var obj = helpers.getNameVariants( arguments.name );
3232
arguments.directory = fileSystemUtil.resolvePath( arguments.directory );
@@ -55,7 +55,12 @@ component
5555
actionContent = allactions;
5656
} else {
5757
// Do Crud: overrwrite whole controllerContent with CRUD template
58-
controllerContent = fileRead( getTemplate( '/CRUDContent.txt' ) );
58+
if(fileExists(fileSystemUtil.resolvePath('app/snippets/CRUDContent.txt'))){
59+
controllerContent = fileRead(fileSystemUtil.resolvePath('app/snippets/CRUDContent.txt'));
60+
}
61+
else{
62+
controllerContent = fileRead( getTemplate( '/CRUDContent.txt' ) );
63+
}
5964
print.yellowLine( 'Generating CRUD' );
6065
}
6166

commands/wheels/generate/model.cfc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ component aliases='wheels g model' extends="../base" {
2525
){
2626

2727
var obj = helpers.getNameVariants(arguments.name);
28-
var directory = fileSystemUtil.resolvePath("models");
28+
var directory = fileSystemUtil.resolvePath("app/models");
2929
//TODO: Refactor into a function that tries to get the app name from the server.json file
3030
var appName = listLast( getCWD(), '/\' );
3131

@@ -44,7 +44,12 @@ component aliases='wheels g model' extends="../base" {
4444
}
4545

4646
// Read in Template
47-
var modelContent = fileRead( getTemplate('/ModelContent.txt'));
47+
if(fileExists(fileSystemUtil.resolvePath('app/snippets/ModelContent.txt'))){
48+
var modelContent = fileRead(fileSystemUtil.resolvePath('app/snippets/ModelContent.txt'));
49+
}
50+
else{
51+
var modelContent = fileRead( getTemplate('/ModelContent.txt'));
52+
}
4853
var modelName = obj.objectNameSingularC & ".cfc";
4954
var modelPath = directory & "/" & modelName;
5055

commands/wheels/generate/property.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ component aliases='wheels g property' extends="../base" {
5959
// Quick Sanity Checks: are we actually adding a property to an existing model?
6060
// Check for existence of model file: NB, DB columns can of course exist without a model file,
6161
// But we should confirm they've got it correct.
62-
if(!fileExists(fileSystemUtil.resolvePath("models/#obj.objectNameSingularC#.cfc"))){
63-
if(!confirm("Hold On! We couldn't find a corresponding Model at /models/#obj.objectNameSingularC#.cfc: are you sure you wish to add the property '#arguments.columnName#' to #obj.objectNamePlural#? [y/n]")){
62+
if(!fileExists(fileSystemUtil.resolvePath("app/models/#obj.objectNameSingularC#.cfc"))){
63+
if(!confirm("Hold On! We couldn't find a corresponding Model at /app/models/#obj.objectNameSingularC#.cfc: are you sure you wish to add the property '#arguments.columnName#' to #obj.objectNamePlural#? [y/n]")){
6464
print.line("Fair enough. Aborting!");
6565
return;
6666
}

commands/wheels/generate/route.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ component aliases='wheels g route' extends="../base" {
99
**/
1010
function run(required string objectname) {
1111
var obj = helpers.getNameVariants(listLast( arguments.objectname, '/\' ));
12-
var target = fileSystemUtil.resolvePath("config/routes.cfm");
12+
var target = fileSystemUtil.resolvePath("app/config/routes.cfm");
1313
var content = fileRead(target);
1414

1515
var inject = '.resources("' & obj.objectNamePlural & '")';

commands/wheels/generate/test.cfc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ component aliases='wheels g test' extends="../base" {
7171
}
7272

7373
// Get test content
74-
var testContent= fileRead(getTemplate("tests/#type#.txt"));
74+
if(fileExists(fileSystemUtil.resolvePath('app/snippets/tests/#type#.txt'))){
75+
var testContent= fileRead(fileSystemUtil.resolvePath('app/snippets/tests/#type#.txt'));
76+
}
77+
else{
78+
var testContent= fileRead(getTemplate("tests/#type#.txt"));
79+
}
7580
file action='write' file='#testPath#' mode ='777' output='#trim( testContent )#';
7681
print.line( 'Created Test Stub #testPath#' );
7782
}

commands/wheels/generate/view.cfc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ component aliases='wheels g view' extends="../base" {
2727
string template=""
2828
){
2929
var obj = helpers.getNameVariants(listLast( arguments.objectname, '/\' ));
30-
var viewdirectory = fileSystemUtil.resolvePath( "views" );
31-
var directory = fileSystemUtil.resolvePath( "views" & "/" & obj.objectNamePlural);
30+
var viewdirectory = fileSystemUtil.resolvePath( "app/views" );
31+
var directory = fileSystemUtil.resolvePath( "app/views" & "/" & obj.objectNamePlural);
3232
print.line( "Creating View File..." ).toConsole();
3333

3434
// Validate directory
@@ -46,9 +46,19 @@ component aliases='wheels g view' extends="../base" {
4646
// Read in Template
4747
var viewContent = "";
4848
if(!len(arguments.template)){
49-
viewContent = fileRead( getTemplate( '/viewContent.txt'));
49+
if(fileExists(fileSystemUtil.resolvePath('app/snippets/viewContent.txt'))){
50+
viewContent = fileRead(fileSystemUtil.resolvePath('app/snippets/viewContent.txt'));
51+
}
52+
else{
53+
viewContent = fileRead( getTemplate( '/viewContent.txt'));
54+
}
5055
} else {
51-
viewContent = fileRead( getTemplate( arguments.template & '.txt'));
56+
if(fileExists(fileSystemUtil.resolvePath('app/snippets/' & arguments.template & '.txt'))){
57+
viewContent = fileRead(fileSystemUtil.resolvePath('app/snippets/' & arguments.template & '.txt'));
58+
}
59+
else{
60+
viewContent = fileRead( getTemplate( arguments.template & '.txt'));
61+
}
5262
}
5363
// Replace Object tokens
5464
viewContent=$replaceDefaultObjectNames(viewContent, obj);

commands/wheels/init.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ component extends="base" {
3636
}
3737

3838
var serverJsonLocation=fileSystemUtil.resolvePath("server.json");
39-
var wheelsBoxJsonLocation=fileSystemUtil.resolvePath("wheels/box.json");
39+
var wheelsBoxJsonLocation=fileSystemUtil.resolvePath("vendor/wheels/box.json");
4040
var boxJsonLocation=fileSystemUtil.resolvePath("box.json");
4141

4242
var wheelsVersion = $getWheelsVersion();

commands/wheels/reload.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ component aliases='wheels r' extends="base" {
2222
var serverDetails = $getServerInfo();
2323

2424
getURL = serverDetails.serverURL &
25-
"/rewrite.cfm?reload=#mode#&password=#password#";
25+
"/public/rewrite.cfm?reload=#mode#&password=#password#";
2626
var loc = new Http( url=getURL ).send().getPrefix();
2727
print.line("Reload Request sent");
2828
}

interceptors/postInstall.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ component {
2020
property name='packageService' inject='packageService';
2121

2222
function postInstall( required struct interceptData ) {
23-
var pluginFolder = fileSystemUtil.resolvePath("plugins");
24-
var isValidWheelsInstallation = directoryExists( fileSystemUtil.resolvePath("wheels")) ? true:false;
23+
var pluginFolder = fileSystemUtil.resolvePath("app/plugins");
24+
var isValidWheelsInstallation = directoryExists( fileSystemUtil.resolvePath("vendor/wheels")) ? true:false;
2525
var isValidPluginsDirectory = directoryExists( pluginFolder ) ? true:false;
2626

2727
if(isValidWheelsInstallation && isValidPluginsDirectory){

0 commit comments

Comments
 (0)