Skip to content

Commit

Permalink
Merge pull request #3 from neokoenig/master
Browse files Browse the repository at this point in the history
Bring up to date
  • Loading branch information
bpamiri authored Nov 20, 2020
2 parents e542478 + cb5adf9 commit 7abd913
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 212 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0.2.5 (TBA)
0.2.10
*

0.2.9
* Removes cfprocessdirective from default bootstrap layout

0.2.8
* Fixes Scaffolding edit routing

0.2.5
* Updates new installation bootstrap flash messages plugin #25 [Peter Amiri, Tom King]
* New Properties added via scaffold now appear in the default index #24 [Peter Amiri]
* Fixes Index templates to use routes and buttonTo Delete Links [Tom King]
* Fixes Encode Attributes as bootstrap template default to form helpers [Tom King]

0.2.4
* Various scaffolding syntax updates for CFWheels 2.0
Expand Down
4 changes: 3 additions & 1 deletion ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ component {
// Module Properties
this.autoMapModels = true;
this.modelNamespace = "wheels";
this.cfmapping = "wheels";

function configure(){
interceptors = [
{ class='#moduleMapping#.interceptors.postInstall' }
];
settings = {
"modulePath": modulePath
}
}

// Runs when module is loaded
Expand Down
180 changes: 1 addition & 179 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,184 +7,6 @@ Skips things like `rails server` which are provided by commandBox already.

Simply run `install cfwheels-cli` from CommandBox to install the the latest release.

To install the master branch, clone to `.CommandBox\cfml\modules\cfwheels-cli` and restart CommandBox;

Ensure that the path has `cfwheels-cli` in it (not `cfwheelscli`) or anything else.

## Commands

### New Application

`wheels new`

Starts a new installation wizard: creates a new CFWheels installation in a folder called `[AppName]` in the current directory. Defaults to the latest production version of CFWheels. TODO: add version (so `wheels new @2.x` or `@1.4.x` etc);

Sets up:

- wheels
- datasource name
- reload password
- application name
- urlrewrite.xml
- turns on url rewriting and sets `index.cfm` in settings
- Copies over DBMigrate and DBMigratebridge plugins required for active record style integration with CLI.
- TODO: templating?

### Scaffolding

Scaffolding creates a full CRUD model, controller & view files from a singluar noun, including DB Migration Schema

TODO: add test scaffolding

TODO: check CamelCasing..

`wheels scaffold [Name]`

Examples:

`wheels scaffold Creditcard`

Will create:

- Model: `/models/Creditcard.cfc` with CRUD actions
- Controller: `/controllers/Creditcards.cfc`
- Test: `/test/controllers/Creditcards_controller_test.cfc` // TODO
- Test: `/test/models/Creditcard_model_test.cfc` // TODO
- DB: `/db/migrate/YYYYMMDDHHMMSS_create_table_creditcards.cfc`
- Views: `/views/creditcards/index.cfm` + Default CRUD files etc

or with optional arguments

`wheels scaffold Creditcard open,debit,credit,close`

Will create:

- Model: `/models/Creditcard.cfc` with specified actions
- Controller: `/controllers/Creditcards.cfc`
- Test: `/test/controllers/Creditcards_controller_test.cfc` // TODO
- Test: `/test/models/Creditcard_model_test.cfc` // TODO
- Views: `/views/creditcards/debit.cfm` [etc]

The `scaffold` command uses the `generate` and `dbmigrate` command internally to do all of this:

### Generate

The `wheels generate` command (alias `wheels g`) uses templates to create a whole lot of things.

`wheels generate [Type] [Name] [Options]`

`wheels generate` takes several sub commands:

- `controller` - Generate a controller with optional specified actions
- `model` - Generates a model file in `/models/`
- `view` - Generates a simple view file in `/views/[name]/[viewName]`
- `test` - Generates test files for model/controller/view in `/test/[name]`
- `property` - Generates a property to add to a model

Examples:

**Controllers**

`wheels generate controller foo`

Generates `Foo.cfc` in `/controllers/` with default CRUD actions (but not view files)

`wheels generate controller foo open,debit,credit,close`

Generates `Foo.cfc` in `/controllers/` with 4 actions - `open,debit,credit,close` (but not view files)

**Models**

`wheels generate model foo`

Generates `Foo.cfc` in `/models/`

**Views**

`wheels generate view foo index`

Generates `index.cfm` in `/views/foo/`
TODO: allow to accept list of actions, i.e, foo,bar,three etc

`wheels generate view foo edit crud/edit`

Generates `edit.cfm` in `/views/foo/` using `templates/crud/edit.txt`

**Tests**

`wheels generate test foo` // TODO

**Properties**

`wheels generate property car registration`

Adds a column to the "Car" DB model, and generates and inserts appropriate form fields.

### DBMigrate

The dbmigrate command powers the DBMigrateplugin via a bridging plugin.
Used in `scaffold/generate` commands for all database interaction.

`wheels dbmigrate info`

Get DB migrate information (list of possible migrations etc) directly from the DBMigrate plugin

`wheels dbmigrate latest`

Migrate to the latest version of the DB schema

`wheels dbmigrate exec 098098098_foo`

Migrate to version 098098098_foo

`wheels dbmigrate exec 0`

Migrate to version 0: this is essentially same as resetting the database

`wheels dbmigrate up`

Go up a version from the current, ultimately till latest version

`wheels dbmigrate down`

Go down a version from the current, ultimate till an empty database

`wheels dbmigrate create [something]`

i.e, `wheels dbmigrate create table dogs` to create the dogs table.
TODO: columns, etc etc

`wheels dbmigrate remove [something]`

i.e, `wheels dbmigrate remove table dogs`: Delete table Dogs

`wheels dbmigrate update [something]`

i.e, `wheels dbmigrate update table dogs`: update table Dogs

`wheels dbmigrate rename [something]`

i.e, `wheels dbmigrate rename table dogs`: Rename Dogs



### Test Suite

Run tests from the command line.

`wheels test core [serverName] [reload] [debug]`

`wheels test app [serverName] [reload] [debug]`

`wheels test plugin [pluginName] [serverName] [debug]`

### Misc

`wheels info`

Displays information about this module, such as Version number

`wheels reload` (alias `wheels r`)

Asks for reload password and trys to restart the wheels app in design mode.
Accepts mode as argument, i.e, `wheels reload production`
See https://guides.cfwheels.org/docs/cli-commands or use `help wheels` in Commandbox.
4 changes: 2 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name":"CFWheels CLI Commands",
"version":"0.2.4",
"version":"0.3.6",
"author":"Tom King",
"location":"neokoenig/cfwheels-cli#v0.2.4",
"location":"neokoenig/cfwheels-cli#v0.3.6",
"directory":"",
"createPackageDirectory":true,
"packageDirectory":"cfwheels-cli",
Expand Down
2 changes: 1 addition & 1 deletion commands/wheels/base.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ component excludeFromHelp=true {
// Return a text field if everything fails, i.e assume string
// Let's escape the output to be safe
default:
rv&="xmlFormat(#objectName#.#property#)";
rv&="encodeForHTML(#objectName#.#property#)";
break;
}
rv&="~]~</p>";
Expand Down
28 changes: 16 additions & 12 deletions commands/wheels/info.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@
**/
component extends="base" {

property name='fileSystem' inject='fileSystem';
/**
*
**/
function run( ) {
var current={
directory =getCWD(),
moduleRoot =expandPath("../modules/cfwheels-cli/"),
wheelsVersion =$getWheelsVersion()
directory = getCWD(),
moduleRoot = expandPath("/cfwheels-cli/"),
wheelsVersion = $getWheelsVersion()
};


print.greenBoldLine( "================CFWheels CLI =======================" )
.greenBoldLine( "This is highly experimental, and will probably fry your brain" )
.greenBoldLine( "====================================================" )
.greenBoldLine( "= Current Working Directory: #current.directory#")
.greenBoldLine( "= CommandBox Module Root: #current.moduleRoot#")
.greenBoldLine( "= Current CFWheels Version in this directory: #current.wheelsVersion#")
.greenBoldLine( "====================================================" );
print.redLine(" ,-----.,------.,--. ,--.,--. ,--. ,-----.,--. ,--. ")
.redLine("' .--./| .---'| | | || ,---. ,---. ,---. | | ,---. ' .--./| | | | ")
.redLine("| | | `--, | |.'.| || .-. || .-. :| .-. :| |( .-' | | | | | | ")
.redLine("' '--'\| |` | ,'. || | | |\ --.\ --.| |.-' `) ' '--'\| '--.| | ")
.redLine(" `-----'`--' '--' '--'`--' `--' `----' `----'`--'`----' `-----'`-----'`--' ")
.yellowBoldLine( "================CFWheels CLI =======================" )
.yellowBoldLine( "This is highly experimental, and will probably fry your brain" )
.yellowBoldLine( "====================================================" )
.yellowBoldLine( "= Current Working Directory: #current.directory#")
.yellowBoldLine( "= CommandBox Module Root: #current.moduleRoot#")
.yellowBoldLine( "= Current CFWheels Version in this directory: #current.wheelsVersion#")
.yellowBoldLine( "====================================================" );
}

}
6 changes: 5 additions & 1 deletion commands/wheels/new.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ component extends="base" {
.greenBoldLine( " 3) Adobe ColdFusion 10 " )
.greenBoldLine( " 4) Adobe ColdFusion 11 " )
.greenBoldLine( " 5) Adobe ColdFusion 2016 " )
.greenBoldLine( " 6) Adobe ColdFusion 2018 " )
.greenBoldLine( "==================================================" )
.line().toConsole();
var defaultEngine= ask('Please enter your preferred engine: [1-5] ');
Expand All @@ -134,6 +135,9 @@ component extends="base" {
case 5:
setEngine="adobe@2016";
break;
case 6:
setEngine="adobe@2018";
break;
}
print.line();

Expand Down Expand Up @@ -213,7 +217,7 @@ component extends="base" {
file action='write' file='#fileSystemUtil.resolvePath("server.json")#' mode ='777' output='#trim(serverJSON)#';
// Copy urlrewrite.xml
command( 'cp' )
.params( path=expandPath("../modules/cfwheels-cli/templates/urlrewrite.xml"), newPath=fileSystemUtil.resolvePath("urlrewrite.xml"))
.params( path=expandPath("/cfwheels-cli/templates/urlrewrite.xml"), newPath=fileSystemUtil.resolvePath("urlrewrite.xml"))
.run();
// Definitely refactor this into some sort of templating system?
if(useBootstrap3){
Expand Down
2 changes: 1 addition & 1 deletion commands/wheels/plugins/list.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* wheels plugins list
* {code}
**/
component aliases="wheels plugin list" extends="base" {
component aliases="wheels plugin list" extends="../base" {

/**
*
Expand Down
78 changes: 78 additions & 0 deletions commands/wheels/travis.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Run Core Wheels Framework Tests (travis) | Internal Use Only
*
* {code:bash}
* wheels travis url=blah
* {code}
*
**/
component extends="base" {

/**
* @url.hint Absolute Path to test json runner, i.e http://127.0.0.1:58432
*/
function run(
required string server,
string runner = "?controller=wheels&action=wheels&view=tests&type=core&format=json",
boolean debug = false
) {

var hiddenCount = 0;
var resultset = "";
var uri = arguments.server & arguments.runner;
var debug = arguments.debug;

print.greenBoldLine( "================Core Travis Tests =======================" ).toConsole();
print.boldCyanLine( "Executing tests, please wait..." )
.blinkingRed( "Please wait...")
.printLine()
.toConsole();
try{
var results = new Http( url=uri ).send().getPrefix();
} catch( any e ){
return error( 'Error executing tests: #CR# #e.message##CR##e.detail#' );
}
if(isJson(results.filecontent)){

var result = deserializeJSON(results.filecontent);

if(result.ok){
print.greenBoldLine( "================ Tests Complete: All Good! =============" );
} else {
print.redBoldLine( "================ Tests Complete: Failures! =============" );
}

print.boldLine( "================ Results: =======================" );
for(r in result.results){
if(r.status != "Success"){
print.boldLine("Test Case:")
.boldRedLine(" #r.cleantestcase#:")
.boldLine("Test Name: :")
.boldRedLine(" #r.testname#:")
.boldLine("Message:")
.line("#Formatter.HTML2ANSI(r.message)#")
.line("----------------------------------------------------")
.line();
} else {
if(debug){
print.greenline("#r.cleantestcase#: #r.testname# :#r.time#");
} else {
hiddenCount++;
}
}
}
print.boldLine( "Output from #hiddenCount# tests hidden");
print.Line("================ Summary: =======================" )
.line("= Tests: #result.numtests#")
.line("= Cases: #result.numcases#")
.line("= Errors: #result.numerrors#")
.line("= Failures: #result.numfailures#")
.line("= Successes: #result.numsuccesses#")
.Line("==================================================" );

} else {
print.line(Formatter.HTML2ANSI(results.filecontent));
}
}

}
Loading

0 comments on commit 7abd913

Please sign in to comment.