Skip to content

Commit

Permalink
Merge pull request #11 from Ortus-Solutions/development
Browse files Browse the repository at this point in the history
v1.5.0
  • Loading branch information
lmajano authored Sep 17, 2024
2 parents 61843bd + d05e0de commit 46079a8
Show file tree
Hide file tree
Showing 55 changed files with 1,676 additions and 10,189 deletions.
2 changes: 1 addition & 1 deletion ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ component {

this.name = "TestBox CLI";
this.version = "@build.version@[email protected]@";
this.cfmapping = "testbox-cli";
this.cfmapping = "testboxCLI";

function configure(){
settings = { templatesPath : modulePath & "/templates" }
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ box install testbox-cli

You can use the CLI for many things like generating tests, harnesses, running tests and more. Please remember that you can always get help on any command by using the `--help` flag.

## BoxLang Generation Support

The CLI will try to detect if you are running a BoxLang server or are in a BoxLang project using the following discovery techniques in order to determine if the command generators should use the BoxLang language or CFML.

- Is the server running in the current directory a BoxLang server
- Do you have a `testbox.runner=boxlang` in your `box.json` file
- Do you have the `language=boxlang` in your `box.json` file

## CFML Generation Support

The CLI will try to detect if you are running a CFML server or are in a CFML project using the following discovery techniques in order to determine if the command generators should use the CFML language or BoxLang.

- Is the server running in the current directory a CFML (Lucee or Adobe) server
- Do you have a `language=cfml` in your `box.json` file

----

## Credits & Contributions
Expand Down
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"TestBox CLI",
"version":"1.4.0",
"version":"1.5.0",
"location":"https://downloads.ortussolutions.com/ortussolutions/commandbox-modules/testbox-cli/@build.version@/[email protected]@.zip",
"slug":"testbox-cli",
"author":"Ortus Solutions, Corp",
Expand Down
71 changes: 0 additions & 71 deletions build/SetupTemplate.cfc

This file was deleted.

14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Internal refactoring for reuse of commands
- BoxLang support for all generation commands and templates
- You can now also use `--boxlang` to generate templates in BoxLang explicitly without detection
- Bundle `displayName` now showing up on the reports
- Updated the `run` command with tons of docs
- Mutually exclusive options for `run` command which never existed before for `bundles` and `directory`

### Bugs

- Using the `useTestBoxLocal` was not working correctly and re-downloading TestBox every time
- TestBox run should use webroot when resolving testbox location in ensureTestBox()

## [1.4.0] - 2024-02-29

### Added
Expand Down
1 change: 0 additions & 1 deletion commands/testbox/apidocs.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ component {
**/
function run(){
var docsUri = "https://apidocs.ortussolutions.com/##/testbox";

command( "browse" ).params( uri: docsUri ).run();
}

Expand Down
21 changes: 12 additions & 9 deletions commands/testbox/create/bdd.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@
* {code}
*
**/
component {

property name="settings" inject="box:modulesettings:testbox-cli";
component extends="testboxCLI.models.BaseCommand" {

/**
* @name.hint Name of the BDD spec to create without the .cfc. For packages, specify name as 'myPackage/myBDDSpec'
* @open.hint Open the file once it is created
* @directory.hint The base directory to create your BDD spec in and creates the directory if it does not exist.
* @name Name of the BDD spec to create without the .cfc. For packages, specify name as 'myPackage/myBDDSpec'
* @open Open the file once it is created
* @directory The base directory to create your BDD spec in and creates the directory if it does not exist.
* @boxlang Is this a boxlang project? else it is a CFML project
**/
function run(
required name,
boolean open = false,
directory = getCWD()
boolean open = false,
directory = getCWD(),
boolean boxlang = isBoxLangProject( getCWD() )
){
isBoxLangProject();
return;

// Allow dot-delimited paths
arguments.name = replace( arguments.name, ".", "/", "all" );

Expand All @@ -46,7 +49,7 @@ component {
print.line();

// Read in Templates
var BDDContent = fileRead( "#variables.settings.templatesPath#/testbox/bdd.txt" );
var BDDContent = fileRead( "#variables.settings.templatesPath#/#arguments.boxlang ? "bx" : "cfml"#/bdd.txt" );

// Write out BDD Spec
var BDDPath= "#arguments.directory#/#name#.cfc";
Expand Down
18 changes: 9 additions & 9 deletions commands/testbox/create/unit.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
* {code}
*
**/
component {

property name="settings" inject="box:modulesettings:testbox-cli";
component extends="testboxCLI.models.BaseCommand" {

/**
* @name.hint Name of the xUnit bundle to create without the .cfc. For packages, specify name as 'myPackage/MyTest'
* @open.hint Open the file once it is created
* @directory.hint The base directory to create your CFC in and creates the directory if it does not exist.
* @name Name of the xUnit bundle to create without the .cfc. For packages, specify name as 'myPackage/MyTest'
* @open Open the file once it is created
* @directory The base directory to create your CFC in and creates the directory if it does not exist.
* @boxlang Is this a boxlang project? else it is a CFML project
**/
function run(
required name,
boolean open = false,
directory = getCWD()
boolean open = false,
directory = getCWD(),
boolean boxlang = isBoxLangProject( getCWD() )
){
// Allow dot-delimited paths
arguments.name = replace( arguments.name, ".", "/", "all" );
Expand All @@ -46,7 +46,7 @@ component {
print.line();

// Read in Templates
var content = fileRead( "#variables.settings.templatesPath#/testbox/unit.txt" );
var content = fileRead( "#variables.settings.templatesPath#/#arguments.boxlang ? "bx" : "cfml"#/unit.txt" );

// Write out BDD Spec
var thisPath= "#arguments.directory#/#name#.cfc";
Expand Down
1 change: 0 additions & 1 deletion commands/testbox/docs.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ component {
**/
function run( string search = "" ){
var docsUri = "https://testbox.ortusbooks.com" & ( search.len() ? "?q=#search#" : "" );

command( "browse" ).params( uri: docsUri ).run();
}

Expand Down
16 changes: 9 additions & 7 deletions commands/testbox/generate/browser.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@
* testbox create browser C:\myApp
* {code}
*/
component {

property name="settings" inject="box:modulesettings:testbox-cli";
component extends="testboxCLI.models.BaseCommand" {

/**
* @directory The base directory to create your test browser
* @boxlang Is this a boxlang project? else it is a CFML project
*/
function run( string directory = getCWD() ){
function run(
string directory = getCWD(),
boolean boxlang = isBoxLangProject( getCWD() )
){
// This will make each directory canonical and absolute
arguments.directory = resolvePath( arguments.directory & "/tests/test-browser" );
arguments.directory = resolvePath( arguments.directory & "/tests/browser" );

// Validate directory
if ( !directoryExists( arguments.directory ) ) {
directoryCreate( arguments.directory );

// Copy template
// Copy template from testbox source
directoryCopy(
"#variables.settings.templatesPath#/testbox/test-browser/",
"#variables.settings.templatesPath#/#arguments.boxlang ? "bx" : "cfml"#/browser/",
arguments.directory,
true
);
Expand Down
16 changes: 9 additions & 7 deletions commands/testbox/generate/harness.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@
* testbox create harness C:\myApp
* {code}
*/
component {

property name="settings" inject="box:modulesettings:testbox-cli";
component extends="testboxCLI.models.BaseCommand" {

/**
* @directory The base directory to create your test harness
* @directory The base directory to create your test browser
* @boxlang Is this a boxlang project? else it is a CFML project
*/
function run( string directory = getCWD() ){
function run(
string directory = getCWD(),
boolean boxlang = isBoxLangProject( getCWD() )
){
// This will make each directory canonical and absolute
arguments.directory = resolvePath( arguments.directory & "/tests" );

// Validate directory
if ( !directoryExists( arguments.directory ) ) {
directoryCreate( arguments.directory );

// Copy template
// Copy template from testbox source
directoryCopy(
"#variables.settings.templatesPath#/testbox/test-harness/",
"#variables.settings.templatesPath#/#arguments.boxlang ? "bx" : "cfml"#/tests/",
arguments.directory,
true
);
Expand Down
10 changes: 5 additions & 5 deletions commands/testbox/generate/module.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
* testbox create module myModule tests/resources/modules
* {code}
*/
component {

property name="settings" inject="box:modulesettings:testbox-cli";
component extends="testboxCLI.models.BaseCommand" {

/**
* @name The name of the module
* @rootDirectory Where to create the module, by default it will be in the same folder as you call the command
* @boxlang Is this a boxlang project? else it is a CFML project
*/
function run(
required name,
string rootDirectory = getCWD()
string rootDirectory = getCWD(),
boolean boxlang = isBoxLangProject( getCWD() )
){
var moduleDirectory = resolvePath( arguments.rootDirectory ) & "/" & arguments.name;

Expand All @@ -31,7 +31,7 @@ component {

// Copy template
directoryCopy(
"#variables.settings.templatesPath#/testbox/module/",
"#variables.settings.templatesPath#/#arguments.boxlang ? "bx" : "cfml"#/module/",
moduleDirectory,
true
);
Expand Down
9 changes: 5 additions & 4 deletions commands/testbox/generate/visualizer.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
* testbox create visualizer C:\myApp
* {code}
*/
component {

property name="settings" inject="box:modulesettings:testbox-cli";
component extends="testboxCLI.models.BaseCommand" {

/**
* @directory The base directory to create your test visualizer
Expand All @@ -22,13 +20,16 @@ component {
// This will make each directory canonical and absolute
arguments.directory = resolvePath( arguments.directory & "/tests/test-visualizer" );

// Make sure we have the latest TestBox for assets
ensureTestBox( false );

// Validate directory
if ( !directoryExists( arguments.directory ) ) {
directoryCreate( arguments.directory );

// Copy template
directoryCopy(
"#variables.settings.templatesPath#/testbox/test-visualizer/",
expandPath( "/testbox/test-visualizer" ),
arguments.directory,
true
);
Expand Down
Loading

0 comments on commit 46079a8

Please sign in to comment.