├── LICENSE.txt ├── ModuleConfig.cfc ├── README.md ├── box.json ├── commands └── fw1 │ ├── create │ ├── app.cfc │ ├── bean.cfc │ ├── clj-controller.cfc │ ├── clj-service.cfc │ ├── controller.cfc │ ├── layout.cfc │ ├── service.cfc │ ├── subsystem.cfc │ └── view.cfc │ ├── install.cfc │ └── version.cfc └── resources ├── skeletons ├── Basic.zip ├── Examples.zip ├── Skeleton.zip ├── Subsystem-Legacy.zip └── Subsystem.zip └── templates └── SubsystemTemplate.zip /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Tony Junkes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /ModuleConfig.cfc: -------------------------------------------------------------------------------- 1 | component { 2 | public void function configure() { 3 | settings = { 4 | "resources": { 5 | "skeletons": "#modulePath#/resources/skeletons/", 6 | "templates": "#modulePath#/resources/templates/" 7 | }, 8 | "version": "2.1.1" 9 | }; 10 | } 11 | 12 | public any function onCLIStart( required struct interceptData ) { } 13 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FW/1 Commands 2 | ### A collection of CommandBox commands for working with FW/1 3 | 4 | ## Installation 5 | 6 | 1. First, make sure you have CommandBox installed. 7 | 2. Fire up your terminal and drop into CommandBox by entering `box`. 8 | 3. Install FW/1 Commands by entering `install fw1-commands`. 9 | 4. Done! 10 | 11 |
12 | 13 | ## Getting Started 14 | 15 | #### Application Skeleton Generation With `fw1 create app` 16 | 17 | To get started quickly, _FW/1 Commands_ comes with a `create app` command that can be used to generate a ready-to-go application skeleton for you. 18 | 19 | ###### _A simple example:_ 20 | 21 | > `fw1 create app MyApp Basic` 22 | 23 | To break it down further, `fw1` is the alias used that tells CommandBox that we are using _FW/1 Commands_. `create app` is instructing to use the `app` command located in the `create` driectory (check out the actual file structure of the command bundle to get a better idea). `MyApp` is the first parameter to be passed to the `app` command. This is the name of your application. `Basic` is the skeleton we chose to use as the base medium for out application structure. 24 | 25 |
26 | 27 | ## A Deeper Look Into `create app` 28 | 29 | ###### `create app` can take up to 5 parameters. 30 | 31 | - `name` (type: string) - The name of your application. Defaults to "My FW/1 App" if no name is supplied. 32 | - `skeleton` (type: string) - The skeleton structure to generate. Defaults to `basic`. 33 | - `directory` (type: string) - The directory to generate the application skeleton in. If it does not exist, it will be created. Defaults to the current working directory. 34 | - `installFW1` (type: boolean) - Flags whether to install the latest version FW/1. Defaults to `false`. 35 | - `package` (type: boolean) - Flags whether to create a `box.json`. Defaults to `true`. 36 | 37 |
38 | 39 | #### Available Skeletons 40 | 41 | - *Examples*: (the examples and introduction folders from the FW/1 repo) - `fw1 create app myApp examples` 42 | - *Skeleton*: (the skeleton folder from the FW/1 repo) - `fw1 create app myApp skeleton` 43 | - *Basic*: (a bare bones setup for a single application) - `fw1 create app myApp basic` 44 | - *Subsystem*: (a bare bones setup for a application using subsystems 2.0 released with FW/1 3.5) - `fw1 create app myApp subsystem` 45 | - *Subsystem Legacy*: (a bare bones setup for a application using subsystems prior to 2.0) - `fw1 create app myApp subsystem-legacy` 46 | 47 |
48 | 49 | #### Choosing A Directory to Generate In 50 | 51 | By default, _FW/1 Commands_ assumes that the current directory you are in on the command line is your current working directory and will generate the application in said directory. Should you need to install elsewhere, you can override this by passing in a path as the third parameter. 52 | 53 | ###### _Example:_ 54 | 55 | > `fw1 create app MyApp basic path/to/my/directory` 56 | 57 |
58 | 59 | #### Including Framework One With Your New Application 60 | 61 | By default, FW/1 is not included with generated skeletons. The option to to use the master or development release is up to you. 62 | 63 | `create app` comes with a fourth parameter, `installFW1`, that when set to `true` will install the latest stable releast of FW/1. When you are in the working directory you want FW/1 to be installed in, you can pass the parmaeter in with double dashes. 64 | 65 | ###### _Examples installing FW/1:_ 66 | 67 | > _Create in current working directory._ - `fw1 create app MyApp basic --installFw1` 68 | > _Create in a specified directory._ - `fw1 create app MyApp basic path/to/directory true` 69 | 70 | To manually install the latest version of FW/1 all you need to do is enter this command in the command line: `install fw1`. To include the dev release, it's the same command but with that release's version number. For example: `install fw1-4.0.0`. Note that the version number must reflect what is available on ForgeBox. To install directly from Github you can do this: `install https://github.com/framework-one/fw1/archive/develop.zip`. 71 | 72 |
73 | 74 | #### Generating Your Application as a Package 75 | 76 | To follow in the CommandBox/ForgeBox scheme of things, a `box.json` with basic package information is generated with your application. This makes your app capable of being added to ForgeBox for others to use and also makes installing it with CommandBox super simple. 77 | 78 | By default this option is set to `true` but can be altered like so: `fw1 create app MyApp basic / false false` 79 | 80 |
81 | 82 | ## Scaffolding Individual Parts of Your Application 83 | 84 | #### Generating Views With `fw1 create view` 85 | 86 | ###### `create view` takes up to 2 parameters. 87 | 88 | - `name` (type: string, _required_) - The name of your view. 89 | - `directory` (type: string) - The directory to generate the view in. If it does not exist, it will be created. Defaults to looking for the `views` directory in your current working directory. 90 | 91 | ###### _Examples:_ 92 | 93 | > _Create in current working directory._ - `fw1 create view myView` 94 | > _Create in specified directory._ - `fw1 create view myView my/directory` 95 | 96 |
97 | 98 | #### Generating Controllers With `fw1 create controller` 99 | 100 | ###### `create controller` takes up to 6 parameters. 101 | 102 | - `name` (type: string, _required_) - The name of your controller. 103 | - `actions` (type: string) - The actions to be included in your controller. A comma delimited list of action names can be passed to create multiple actions. By default, only `default` is generated in the controller. 104 | - `directory` (type: string) - The directory to generate the controller in. If it does not exist, it will be created. Defaults to looking for the `controllers` directory in your current working directory. 105 | - `views` (type: boolean) - A flag to determine whether to generate views for each action. Defaults to `true`. 106 | - `viewsDirectory` (type: string) - The directory to generate the controller's views in. If it does not exist, it will be created. Defaults to looking for the `views` directory in path supplied to the `directory` parameter. 107 | - `open` (type: boolean) - A flag to determine whether to open the generated controller for editing right away. Opens in your machine's default editor. Defaults to `false`. 108 | 109 | ###### _Examples:_ 110 | 111 | > _Create in current working directory._ - `fw1 create controller myController` 112 | > _Create with multiple actions._ - `fw1 create controller myController list,add,edit,delete` 113 | > _Create and open in editor._ - `fw1 create controller myController myAction --open` 114 | > _Create in specified directory._ `fw1 create controller myController myAction my/controller/directory` 115 | > _Create and generate views for each action._ - `fw1 create controller myController myAction controllers true` 116 | > _Create controller, views and specify the views directory._ - `fw1 create controller myController myAction controllers true my/view/directory` 117 | > _Create controller, views and open in editor._ - `fw1 create controller myController myAction controllers true my/view/directory true` 118 | 119 |
120 | 121 | #### Generating Layouts With `fw1 create layout` 122 | 123 | ###### `create layout` takes up to 2 parameters. 124 | 125 | - `name` (type: string, _required_) - The name of your layout. 126 | - `directory` (type: string) - The directory to generate the layout in. If it does not exist, it will be created. Defaults to looking for the `layouts` directory in your current working directory. 127 | 128 | ###### _Examples:_ 129 | 130 | > _Create in current working directory._ - `fw1 create layout myLayout` 131 | > _Create in specified directory._ `fw1 create layout myLayout my/layouts` 132 | 133 |
134 | 135 | #### Generating Beans With `fw1 create bean` 136 | 137 | ###### `create bean` takes up to 4 parameters. 138 | 139 | - `name` (type: string, _required_) - The name of your bean. A comma delimited list of beans can be passed to be created in bulk. To specify "package" directorys, include the base path to be found/generated. Example: package/path/to/Bean. 140 | - `directory` (type: string) - The directory to generate the bean in. If it does not exist, it will be created. Defaults to looking for the `model/beans` directory in your current working directory. 141 | - `camelCase` (type: boolean) - A flag to determine the naming convention of the bean file to be in _camel case_ format. For example: _MyBean.cfc_. Defaults to `true`. 142 | - `open` (type: boolean) - A flag to determine whether to open the generated bean for editing right away. Opens in your machine's default editor. Defaults to `false`. 143 | 144 | ###### _Examples:_ 145 | 146 | > _Create in current working directory._ - `fw1 create bean MyBean` 147 | > _Create and open in editor._ - `fw1 create bean MyBean --open` 148 | > _Create and specify package directory structure._ - `fw1 create bean package/path/for/MyBean` 149 | > _Create multiple beans._ - `fw1 create bean MyBean,MyOtherBean` 150 | > _Create in specified directory._ - `fw1 create bean MyBean path/to/beans` 151 | > _Create without camel case formatted file name._ - `fw1 create bean MyBean model/beans false` 152 | > _Create without camel case formatted file name and open in editor._ - `fw1 create bean MyBean model/beans false true` 153 | 154 |
155 | 156 | #### Generating Services With `fw1 create service` 157 | 158 | ###### `create service` takes up to 4 parameters. 159 | 160 | - `name` (type: string, _required_) - The name of your service. A comma delimited list of services can be passed to be created in bulk. To specify "package" directorys, include the base path to be found/generated. Example: package/path/to/Service. 161 | - `directory` (type: string) - The directory to generate the service in. If it does not exist, it will be created. Defaults to looking for the `model/services` directory in your current working directory. 162 | - `camelCase` (type: boolean) - A flag to determine the naming convention of the service file to be in _camel case_ format. For example: _MyService.cfc_. Defaults to `true`. 163 | - `open` (type: boolean) - A flag to determine whether to open the generated service for editing right away. Opens in your machine's default editor. Defaults to `false`. 164 | 165 | ###### _Examples:_ 166 | 167 | > _Create in current working directory._ - `fw1 create service MyService` 168 | > _Create and open in editor._ - `fw1 create service MyService --open` 169 | > _Create and specify package directory structure._ - `fw1 create service package/path/for/MyService` 170 | > _Create multiple services._ - `fw1 create service MyService,MyOtherService` 171 | > _Create in specified directory._ - `fw1 create service MyService path/to/services` 172 | > _Create without camel case formatted file name._ - `fw1 create service MyService model/services false` 173 | > _Create without camel case formatted file name and open in editor._ - `fw1 create service MyService model/services false true` 174 | 175 |
176 | 177 | #### Generating Subsytem Skeletons With `fw1 create subsystem` 178 | 179 | ###### `create subsystem` takes up to 2 parameters and will generate a bare bones subsytem file structure. 180 | 181 | - `name` (type: string, _required_) - The name of your subsystem. 182 | - `directory` (type: string) - The directory to generate the subsystem in. If it does not exist, it will be created. Defaults to looking for the `subsystems` directory in your current working directory based on the Subsystem 2.0 convention released with FW/1 3.5. 183 | 184 | ###### _Examples:_ 185 | 186 | > _Create from current working directory._ - `fw1 create subsystem mysubsystem` 187 | > _Create in specified directory._ - `fw1 create subsystem mysubsystem my/subsystems` 188 | 189 |
190 | 191 | #### Generating Clojure Controllers For FW/1 3.5+ With `fw1 create clj-controller` 192 | 193 | ###### `create clj-controller` takes up to 4 parameters. 194 | 195 | - `name` (type: string, _required_) - The name of your controller. 196 | - `actions` (type: string) - The actions to be included in your controller. A comma delimited list of action names can be passed to create multiple actions. By default, only `default` is generated in the controller. 197 | - `directory` (type: string) - The directory to generate the controller in. If it does not exist, it will be created. Defaults to looking for the `controllers` directory in your current working directory. 198 | - `open` (type: boolean) - A flag to determine whether to open the generated controller for editing right away. Opens in your machine's default editor. Defaults to `false`. 199 | 200 | ###### _Examples:_ 201 | 202 | > _Create in current working directory._ `fw1 create clj-controller my-controller` 203 | > _Create with multiple actions._ - `fw1 create clj-controller my-controller list,add,edit,delete` 204 | > _Create and open in editor._ - `fw1 create clj-controller my-controller --open` 205 | > _Create in specified directory._ - `fw1 create clj-controller my-controller my-action my/controller/directory` 206 | > _Create, specify actions, directory and open in editor._ - `fw1 create clj-controller my-controller my-action controllers true` 207 | 208 |
209 | 210 | #### Generating Clojure Services For FW/1 3.5+ With `fw1 create clj-service` 211 | 212 | ###### `create clj-service` takes up to 3 parameters. 213 | 214 | - `name` (type: string, _required_) - The name of your service. A comma delimited list of services can be passed to be created in bulk. To specify "package" directorys, include the base path to be found/generated. Example: package/path/to/Service. 215 | - `directory` (type: string) - The directory to generate the service in. If it does not exist, it will be created. Defaults to looking for the `services` directory in your current working directory. 216 | - `open` (type: boolean) - A flag to determine whether to open the generated service for editing right away. Opens in your machine's default editor. Defaults to `false`. 217 | 218 | ###### _Examples:_ 219 | 220 | > _Create in current working directory._ - `fw1 create clj-service my-service` 221 | > _Create and open in editor._ - `fw1 create clj-service my-service --open` 222 | > _Create and specify package directory structure._ - `fw1 create clj-service package/path/for/my-service` 223 | > _Create multiple services._ - `fw1 create clj-service my-service,my-other-service` 224 | > _Create in specified directory._ - `fw1 create clj-service my-service path/to/services` 225 | > _Create, specify directory and open in editor._ - `fw1 create clj-service my-service services true` 226 | -------------------------------------------------------------------------------- /box.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "FW/1 Commands", 3 | "slug" : "fw1-commands", 4 | "version" : "2.1.1", 5 | "author" : "Tony Junkes - @cfchef", 6 | "location" : "https://github.com/framework-one/fw1-commands/archive/master.zip", 7 | "Homepage" : "https://github.com/framework-one/fw1-commands", 8 | "Documentation" : "https://github.com/framework-one/fw1-commands/blob/master/README.md", 9 | "Repository" : { 10 | "type" : "git", "URL" : "https://github.com/framework-one/fw1-commands.git" 11 | }, 12 | "Bugs" : "https://github.com/framework-one/fw1-commands/issues", 13 | "shortDescription" : "A collection of CommandBox commands for FW/1.", 14 | "description" : "A collection of CommandBox commands for FW/1.", 15 | "instructions" : "https://github.com/framework-one/fw1-commands/blob/master/README.md", 16 | "changelog" : "https://github.com/framework-one/fw1-commands/commits/master", 17 | "type" : "commandbox-modules", 18 | "keywords" : [ "fw1", "framework one", "commandbox", "commands" ], 19 | "private" : "false", 20 | "License" : [ 21 | { "type" : "MIT" } 22 | ], 23 | "Contributors" : [ {"name": "Contributors List", "url": "https://github.com/framework-one/fw1-commands/graphs/contributors"} ], 24 | "ignore" : [ "*.md", "*.txt" ] 25 | } 26 | -------------------------------------------------------------------------------- /commands/fw1/create/app.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create an FW/1 application from one of the available skeletons: 3 | * . 4 | * - Examples 5 | * - Skeleton 6 | * - Basic 7 | * - Subsystem 8 | * - Subsystem-Legacy 9 | * . 10 | * {code:bash} 11 | * fw1 create app myApp 12 | * {code} 13 | * . 14 | * By default the "Basic" skeleton will be installed as the application skeleton. 15 | * . 16 | * By default, the application will be installed in the current working directory 17 | * but can be overridden. 18 | * . 19 | * {code:bash} 20 | * fw1 create app myApp basic my/directory 21 | * {code} 22 | * . 23 | * By default, your application will be created as a package to be used by CommandBox 24 | * for other applications and ForgeBox. This can be altered by setting "package" to false. 25 | * . 26 | * {code:bash} 27 | * fw1 create app myApp basic / false 28 | * {code} 29 | * . 30 | * Use "installFW1" to install the latest stable release of FW/1 from ForgeBox. 31 | * . 32 | * {code:bash} 33 | * fw1 create app myApp --installFW1 34 | * {code} 35 | * . 36 | * Use "startSever" to have CommandBox start a server that 37 | * will run your app after generation. 38 | * . 39 | * {code:bash} 40 | * fw1 create app myApp --startServer 41 | * {code} 42 | */ 43 | component displayname="FW/1 Create Application Command" 44 | excludeFromHelp=false 45 | { 46 | property name="packageService" inject="PackageService"; 47 | property name="settings" inject='commandbox:moduleSettings:fw1-commands'; 48 | 49 | /** 50 | * @name.hint The name of the app being created. 51 | * @skeleton.hint The name of the app skeleton to generate. 52 | * @skeleton.options Examples, Skeleton, Basic, Subsystem, Subsystem-Legacy 53 | * @directory.hint The directory to create the app in. Defaults to current working directory. 54 | * @installFW1.hint Install the latest stable version of FW/1 from ForgeBox. 55 | * @package.hint Generate a box.json to make the current directory a package. 56 | * @startServer.hint Have CommandBox start a server that will run your app after generation. 57 | */ 58 | public void function run( 59 | string name = "My FW/1 App", 60 | string skeleton = "Basic", 61 | string directory = getCWD(), 62 | boolean package = true, 63 | boolean installFW1 = false, 64 | boolean startServer = false 65 | ) { 66 | // Prevent any case issues with some Operating Systems 67 | arguments.skeleton = arguments.skeleton.lCase(); 68 | // This will make the directory canonical and absolute 69 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 70 | // Get the skeleton resource to use 71 | var skeletonZip = settings.resources.skeletons & arguments.skeleton & ".zip"; 72 | // Validate skeleton 73 | if ( !fileExists( skeletonZip ) ) { 74 | var options = directoryList( path = settings.resources.skeletons, listInfo = "name", sort = "name" ); 75 | return error( "The app skeleton [#skeletonZip#] doesn't exist. Valid options are #options.toList( ', ' ).replaceNoCase( '.zip', '', 'all' )#." ); 76 | } 77 | // Validate directory, if it doesn't exist, create it 78 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 79 | // Unzip the skeleton 80 | zip action="unzip" destination="#arguments.directory#" file="#skeletonZip#"; 81 | // Success message 82 | print.line().greenLine( "FW/1 (#arguments.skeleton#) application successfully generated in [#arguments.directory#]!" ); 83 | // Create app as a package 84 | if ( arguments.package && !packageService.isPackage( arguments.directory ) ) { 85 | shell.cd( arguments.directory ); 86 | command( "init" ).params( name = arguments.name, slug = arguments.name.replace( ' ', '', 'all' ) ).run(); 87 | shell.cd( getCWD() ); 88 | } 89 | // Install FW/1 from ForgeBox 90 | if ( arguments.installFW1 ) { 91 | command( "install" ).params( id = "fw1", directory = arguments.directory ).run(); 92 | } 93 | // Start a server to begin using generated app 94 | if ( arguments.startServer ) { command( "server start" ).run(); } 95 | } 96 | } -------------------------------------------------------------------------------- /commands/fw1/create/bean.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a new bean in an existing FW/1 application. 3 | * . 4 | * {code:bash} 5 | * fw1 create bean MyBean 6 | * {code} 7 | * . 8 | * The command can also take a list of beans. 9 | * . 10 | * {code:bash} 11 | * fw1 create bean MyBean,MyOtherBean 12 | * {code} 13 | * . 14 | * By default, the bean will be created in "/model/beans" but can be 15 | * overridden. 16 | * . 17 | * {code:bash} 18 | * fw1 create bean MyBean myDirectory 19 | * {code} 20 | * . 21 | * Bean file names are formatted as camel case. 22 | * This can be altered by setting camelCase to false. 23 | * . 24 | * {code:bash} 25 | * fw1 create bean MyBean /model/beans false 26 | * {code} 27 | * . 28 | * Once created, the bean can be opened in your default editor by 29 | * setting the "open" param to true. 30 | * . 31 | * {code:bash} 32 | * fw1 create bean MyBean --open 33 | * {code} 34 | */ 35 | component displayname="FW/1 Create Bean Command" 36 | excludeFromHelp=false 37 | { 38 | /** 39 | * @name.hint Name of the bean to create. For packages, specify name as 'myPackage/MyBean' 40 | * @directory.hint The base directory to create your bean in. Defaults to 'beans'. 41 | * @camelCase.hint Generate the bean file name as camel case. 42 | * @open.hint Open the bean once generated. 43 | */ 44 | public void function run( 45 | required string name, 46 | string directory = "model/beans", 47 | boolean camelCase = true, 48 | boolean open = false 49 | ) { 50 | // This will make each directory canonical and absolute 51 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 52 | // Validate directory 53 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 54 | // Generate beans 55 | arguments.name.listToArray().each(function( bean ) { 56 | // Allow dot-delimited paths 57 | bean = bean.replace( ".", "/", "all" ); 58 | // Make bean name intital caps? 59 | var beanName = camelCase 60 | ? bean.listLast( "/" ).reReplace( "\b(\w)", "\u\1", "all" ) 61 | : bean.listLast( "/" ); 62 | // This helps readability so the success messages aren't up against the previous command line 63 | print.line(); 64 | // Generate bean with init function 65 | savecontent variable="beanContent" { 66 | writeOutput( 'component displayname="#beanName# bean" {' & cr ); 67 | writeOutput( chr(9) & "public #beanName# function init() {" & cr ); 68 | writeOutput( chr(9) & chr(9) & "return this;" & cr ); 69 | writeOutput( chr(9) & "}" ); 70 | writeOutput( cr & "}" ); 71 | } 72 | var beanPath = "#directory#/#beanName#.cfc"; 73 | // Create dir if it doesn't exist 74 | directoryCreate( getDirectoryFromPath( beanPath ), true, true ); 75 | // Create files 76 | file action="write" file="#beanPath#" mode="777" output="#beanContent#"; 77 | print.greenLine( "Created #beanPath#" ); 78 | // Open file 79 | if ( open ){ openPath( beanPath ); } 80 | }); 81 | } 82 | } -------------------------------------------------------------------------------- /commands/fw1/create/clj-controller.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a new Clojure controller in an existing FW/1 application. 3 | * NOTE: This command assumes you are working in the base directory of 4 | * the Clojure application generated to work with FW/1! 5 | * . 6 | * {code:bash} 7 | * fw1 create clj-controller my-controller 8 | * {code} 9 | * . 10 | * By default, only the "default" action is generated but can be overridden to 11 | * include a list of actions. 12 | * . 13 | * {code:bash} 14 | * fw1 create clj-controller my-controller list,add,edit,delete 15 | * {code} 16 | * . 17 | * By default, the controller will be created in "/controllers" but can be 18 | * overridden. 19 | * . 20 | * {code:bash} 21 | * fw1 create clj-controller my-controller my/directory 22 | * {code} 23 | * . 24 | * Once created, the controller can be opened in your default editor by 25 | * setting the "open" param to true. 26 | * . 27 | * {code:bash} 28 | * fw1 create controller my-controller --open 29 | * {code} 30 | */ 31 | component displayname="FW/1 Create Clojure Controller Command" 32 | excludeFromHelp=false 33 | { 34 | /** 35 | * @name.hint Name of the controller to create. 36 | * @actions.hint A comma-delimited list of actions to generate 37 | * @directory.hint The base directory to create your controller in. Defaults to 'controllers'. 38 | * @open.hint Open the controller once generated. 39 | */ 40 | public void function run( 41 | required string name, 42 | string actions = "default", 43 | string directory = "controllers", 44 | boolean open = false 45 | ) { 46 | // This will make each directory canonical and absolute 47 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 48 | // Validate directory 49 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 50 | // This helps readability so the success messages aren't up against the previous command line 51 | print.line(); 52 | // Generate controller with actions passed 53 | var controllerContent = scaffoldController( arguments.name, arguments.actions.listToArray() ); 54 | var controllerPath = "#arguments.directory#/#arguments.name#.clj"; 55 | // Create dir if it doesn't exist 56 | directoryCreate( getDirectoryFromPath( controllerPath ), true, true ); 57 | // Create files 58 | file action="write" file="#controllerPath#" mode="777" output="#controllerContent#"; 59 | print.greenLine( "Created #controllerPath#" ); 60 | // Open file 61 | if ( arguments.open ){ openPath( controllerPath ); } 62 | } 63 | 64 | private string function scaffoldController( 65 | required string name, 66 | array actions = ["default"] 67 | ) { 68 | savecontent variable="controller" { 69 | var index = 0; 70 | writeOutput( "(ns change-me-to-project-name.controllers.#arguments.name#)" & cr & cr ); 71 | arguments.actions.each(function( action, index ) { 72 | writeOutput( "(defn #action# [rc]" & cr ); 73 | writeOutput( chr(32) & chr(32) & '(assoc rc :hello (str "Hello from #action#!")))' ); 74 | if ( index != actions.len() ) { writeOutput( cr & cr ) } 75 | }); 76 | } 77 | 78 | return controller; 79 | } 80 | } -------------------------------------------------------------------------------- /commands/fw1/create/clj-service.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a new Clojure service in an existing FW/1 application. 3 | * NOTE: This command assumes you are working in the base directory of 4 | * the Clojure application generated to work with FW/1! 5 | * . 6 | * {code:bash} 7 | * fw1 create service my-service 8 | * {code} 9 | * . 10 | * The command can also take a list of services to create. 11 | * . 12 | * {code:bash} 13 | * fw1 create service my-service,my-other-service 14 | * {code} 15 | * . 16 | * By default, the service will be created in "/services" but can be 17 | * overridden. 18 | * . 19 | * {code:bash} 20 | * fw1 create service my-service my/directory 21 | * {code} 22 | * . 23 | * Once created, the service can be opened in your default editor by 24 | * setting the "open" param to true. 25 | * . 26 | * {code:bash} 27 | * fw1 create service my-service --open 28 | * {code} 29 | */ 30 | component displayname="FW/1 Create Clojure Service Command" 31 | excludeFromHelp=false 32 | { 33 | /** 34 | * @name.hint Name of the service to create. For packages, specify name as 'my/package/my-service' 35 | * @directory.hint The base directory to create your service in. Defaults to 'services'. 36 | * @open.hint Open the service once generated. 37 | */ 38 | public void function run( 39 | required string name, 40 | string directory = "services", 41 | boolean open = false 42 | ) { 43 | // This will make each directory canonical and absolute 44 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 45 | // Validate directory 46 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 47 | // Generate services 48 | arguments.name.listToArray().each(function( service ) { 49 | // Allow dot-delimited paths 50 | service = service.replace( ".", "/", "all" ); 51 | // Grab service name from possible package structure in name parameter 52 | var serviceName = service.listLast( "/" ); 53 | // This helps readability so the success messages aren't up against the previous command line 54 | print.line(); 55 | // Generate service with dummy function 56 | savecontent variable="serviceContent" { 57 | writeOutput( "(ns change-me-to-project-name.services.#serviceName#)" & cr & cr ); 58 | writeOutput( "(defn hello-world []" & cr ); 59 | writeOutput( chr(32) & chr(32) & '(str "Hello from #serviceName# service!"))' ); 60 | } 61 | var servicePath = "#directory#/#service#.clj"; 62 | // Create dir if it doesn't exist 63 | directoryCreate( getDirectoryFromPath( servicePath ), true, true ); 64 | // Create files 65 | file action="write" file="#servicePath#" mode="777" output="#serviceContent#"; 66 | print.greenLine( "Created #servicePath#" ); 67 | // Open file 68 | if ( open ){ openPath( servicePath ); } 69 | }); 70 | } 71 | } -------------------------------------------------------------------------------- /commands/fw1/create/controller.cfc: -------------------------------------------------------------------------------- 1 | // BASED FROM THE COLDBOX "CONTROLLER.CFC" COMMAND - https://github.com/Ortus-Solutions/commandbox/tree/master/src/cfml/commands/coldbox/create 2 | /** 3 | * Create a new controller in an existing FW/1 application. 4 | * . 5 | * {code:bash} 6 | * fw1 create controller myController 7 | * {code} 8 | * . 9 | * By default, only the "default" action is generated but can be overridden to 10 | * include a list of actions. 11 | * . 12 | * {code:bash} 13 | * fw1 create controller myController list,add,edit,delete 14 | * {code} 15 | * . 16 | * By default, the controller will be created in /controllers but can be 17 | * overridden. 18 | * . 19 | * {code:bash} 20 | * fw1 create controller myController default my/directory 21 | * {code} 22 | * . 23 | * Views are auto-generated in a /views folder by default but can be overridden. 24 | * . 25 | * {code:bash} 26 | * fw1 create controller myController default controllers false 27 | * {code} 28 | * . 29 | * The directory for the views can be overridden as well. 30 | * . 31 | * {code:bash} 32 | * fw1 create controller myController default controllers true my/views 33 | * {code} 34 | * . 35 | * Once created, the controller can be opened in your default editor by 36 | * setting the "open" param to true. 37 | * . 38 | * {code:bash} 39 | * fw1 create controller myController --open 40 | * {code} 41 | */ 42 | component displayname="FW/1 Create Controller Command" 43 | excludeFromHelp=false 44 | { 45 | /** 46 | * @name.hint Name of the controller to create. 47 | * @actions.hint A comma-delimited list of actions to generate 48 | * @directory.hint The base directory to create your controller in. Defaults to 'controllers'. 49 | * @views.hint Generate a view for each action. 50 | * @viewsDirectory.hint The directory where your views are stored. 51 | * @open.hint Open the controller once generated. 52 | */ 53 | public void function run( 54 | required string name, 55 | string actions = "default", 56 | string directory = "controllers", 57 | boolean views = true, 58 | string viewsDirectory = "views", 59 | boolean open = false 60 | ) { 61 | // This will make each directory canonical and absolute 62 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 63 | arguments.viewsDirectory = fileSystemUtil.resolvePath( arguments.viewsDirectory ); 64 | // Validate directory 65 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 66 | // Allow dot-delimited paths 67 | arguments.name = arguments.name.replace( ".", "/", "all" ); 68 | // This helps readability so the success messages aren't up against the previous command line 69 | print.line(); 70 | // Generate controller with actions passed 71 | var controllerContent = scaffoldController( arguments.name, arguments.actions.listToArray() ); 72 | var controllerPath = "#arguments.directory#/#arguments.name#.cfc"; 73 | // Create dir if it doesn't exist 74 | directoryCreate( getDirectoryFromPath( controllerPath ), true, true ); 75 | // Create files 76 | file action="write" file="#controllerPath#" mode="777" output="#controllerContent#"; 77 | print.greenLine( "Created #controllerPath#" ); 78 | // Create views? 79 | if ( arguments.views ) { 80 | arguments.actions.listToArray().each(function( action ) { 81 | var viewPath = viewsDirectory & "/" & name & "/" & action & ".cfm"; 82 | // Create dir if it doesn't exist 83 | directoryCreate( getDirectoryFromPath( viewPath ), true, true ); 84 | // Create view 85 | fileWrite( viewPath, "#cr##chr(9)#

#name#.#action#

#cr#
" ); 86 | print.greenLine( "Created " & viewsDirectory & "/" & name & "/" & action & ".cfm" ); 87 | }); 88 | } 89 | // Open file 90 | if ( arguments.open ){ openPath( controllerPath ); } 91 | } 92 | 93 | private string function scaffoldController( 94 | required string name, 95 | array actions = ["default"] 96 | ) { 97 | savecontent variable="controller" { 98 | writeOutput( 'component displayname="#arguments.name# controller" {' & cr ); 99 | arguments.actions.each(function( action, index ) { 100 | writeOutput( chr(9) & "public void function #action#(struct rc = {}) {" & cr ); 101 | writeOutput( chr(9) & chr(9) & cr ); 102 | writeOutput( chr(9) & "}" ); 103 | if ( index != actions.len() ) { writeOutput( cr & cr ) } 104 | }); 105 | writeOutput( cr & "}" ); 106 | } 107 | 108 | return controller; 109 | } 110 | } -------------------------------------------------------------------------------- /commands/fw1/create/layout.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a new layout in an existing FW/1 application. 3 | * . 4 | * {code:bash} 5 | * fw1 create layout myLayout 6 | * {code} 7 | * . 8 | * By default, the layout will be created in /layouts but can be overridden. 9 | * . 10 | * {code:bash} 11 | * fw1 create layout myLayout my/directory 12 | * {code} 13 | */ 14 | component displayname="FW/1 Create Layout Command" 15 | excludeFromHelp=false 16 | { 17 | /** 18 | * @arguments.name.hint Name of the layout to create. 19 | * @directory.hint The base directory to create your layout in. 20 | */ 21 | public void function run( 22 | required string name, 23 | string directory = "layouts" 24 | ) { 25 | // This will make each directory canonical and absolute 26 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 27 | // Validate directory 28 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 29 | // This help readability so the success messages aren't up against the previous command line 30 | print.line(); 31 | // Default content to be generated in the layout 32 | var layoutContent = "

#arguments.name# Layout

#cr###body##"; 33 | // Create layout 34 | var layoutPath = "#arguments.directory#/#arguments.name#.cfm"; 35 | file action="write" file="#layoutPath#" mode="777" output="#layoutContent#"; 36 | print.greenLine( "Created #layoutPath#" ); 37 | } 38 | } -------------------------------------------------------------------------------- /commands/fw1/create/service.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a new service in an existing FW/1 application. 3 | * . 4 | * {code:bash} 5 | * fw1 create service MyService 6 | * {code} 7 | * . 8 | * The command can also take a list of services to create. 9 | * . 10 | * {code:bash} 11 | * fw1 create service MyService,MyOtherService 12 | * {code} 13 | * . 14 | * By default, the service will be created in "/model/services" but can be 15 | * overridden. 16 | * . 17 | * {code:bash} 18 | * fw1 create service MyService my/directory 19 | * {code} 20 | * . 21 | * Service file names are formatted as camel case. 22 | * This can be altered by setting camelCase to false. 23 | * . 24 | * {code:bash} 25 | * fw1 create service MyService /model/services false 26 | * {code} 27 | * . 28 | * Once created, the service can be opened in your default editor by 29 | * setting the "open" param to true. 30 | * . 31 | * {code:bash} 32 | * fw1 create service MyService --open 33 | * {code} 34 | */ 35 | component displayname="FW/1 Create service Command" 36 | excludeFromHelp=false 37 | { 38 | /** 39 | * @name.hint Name of the service to create. For packages, specify name as 'my/package/MyService' 40 | * @directory.hint The base directory to create your service in. Defaults to 'services'. 41 | * @open.hint Open the service once generated. 42 | */ 43 | public void function run( 44 | required string name, 45 | string directory = "model/services", 46 | boolean camelCase = true, 47 | boolean open = false 48 | ) { 49 | // This will make each directory canonical and absolute 50 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 51 | // Validate directory 52 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 53 | // Generate services 54 | arguments.name.listToArray().each(function( service ) { 55 | // Allow dot-delimited paths 56 | service = service.replace( ".", "/", "all" ); 57 | // Make service name intital caps? 58 | var serviceName = camelCase 59 | ? service.listLast( "/" ).reReplace( "\b(\w)", "\u\1", "all" ) 60 | : service.listLast( "/" ); 61 | // This helps readability so the success messages aren't up against the previous command line 62 | print.line(); 63 | // Generate service with init function 64 | savecontent variable="serviceContent" { 65 | writeOutput( 'component displayname="#serviceName# service" {' & cr ); 66 | writeOutput( chr(9) & "public #serviceName# function init() {" & cr ); 67 | writeOutput( chr(9) & chr(9) & "return this;" & cr ); 68 | writeOutput( chr(9) & "}" ); 69 | writeOutput( cr & "}" ); 70 | } 71 | var servicePath = "#directory#/#serviceName#.cfc"; 72 | // Create dir if it doesn't exist 73 | directoryCreate( getDirectoryFromPath( servicePath ), true, true ); 74 | // Create files 75 | file action="write" file="#servicePath#" mode="777" output="#serviceContent#"; 76 | print.greenLine( "Created #servicePath#" ); 77 | // Open file 78 | if ( open ){ openPath( servicePath ); } 79 | }); 80 | } 81 | } -------------------------------------------------------------------------------- /commands/fw1/create/subsystem.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a individual FW/1 subsystem skeleton structure. 3 | * . 4 | * {code:bash} 5 | * fw1 create subsystem mySubsystem 6 | * {code} 7 | * . 8 | * By default, the subsystem will be created in the current working directory 9 | * but can be overridden. 10 | * . 11 | * {code:bash} 12 | * fw1 create subsystem mySubsystem my/directory 13 | * {code} 14 | */ 15 | component displayname="FW/1 Create Subsystem Command" 16 | excludeFromHelp=false 17 | { 18 | property name="settings" inject='commandbox:moduleSettings:fw1-commands'; 19 | 20 | /** 21 | * @name.hint The name of the subsystem being created. 22 | * @directory.hint The directory to create the subsytem in. Defaults to the subsystem name passed in. 23 | */ 24 | public void function run( 25 | required string name, 26 | string directory = "subsystems" 27 | ) { 28 | var templates = settings.resources.templates; 29 | // This will make the directory canonical and absolute 30 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 31 | // Validate directory, if it doesn't exist, create it 32 | if ( !directoryExists( arguments.directory & "/" & arguments.name ) ) { 33 | directoryCreate( arguments.directory & "/" & arguments.name ); 34 | } 35 | // Unzip the skeleton 36 | zip action="unzip" destination="#arguments.directory#/#arguments.name#" file="#templates#SubsystemTemplate.zip"; 37 | // Success message 38 | print.line().greenLine( 39 | "#arguments.name# subsystem successfully created in [#arguments.directory#]" 40 | ); 41 | } 42 | } -------------------------------------------------------------------------------- /commands/fw1/create/view.cfc: -------------------------------------------------------------------------------- 1 | // BASED FROM THE COLDBOX "VIEW.CFC" COMMAND - https://github.com/Ortus-Solutions/commandbox/tree/master/src/cfml/commands/coldbox/create 2 | /** 3 | * Create a new view in an existing FW/1 application. 4 | * . 5 | * {code:bash} 6 | * fw1 create view myView 7 | * {code} 8 | * . 9 | * By default, the view will be created in /views but can be overridden. 10 | * . 11 | * {code:bash} 12 | * fw1 create view myView my/directory 13 | * {code} 14 | */ 15 | component displayname="FW/1 Create View Command" 16 | excludeFromHelp=false 17 | { 18 | /** 19 | * @name.hint Name of the view to create. 20 | * @directory.hint The base directory to create your view in. Defaults to current working directory. 21 | */ 22 | public void function run( 23 | required string name, 24 | string directory = "views" 25 | ) { 26 | // This will make each directory canonical and absolute 27 | arguments.directory = fileSystemUtil.resolvePath( arguments.directory ); 28 | // Validate directory 29 | if ( !directoryExists( arguments.directory ) ) { directoryCreate( arguments.directory ); } 30 | // This help readability so the success messages aren't up against the previous command line 31 | print.line(); 32 | // Default content to be generated in the view 33 | var viewContent = "

#arguments.name# view

"; 34 | // Create view 35 | var viewPath = "#arguments.directory#/#arguments.name#.cfm"; 36 | file action="write" file="#viewPath#" mode="777" output="#viewContent#"; 37 | print.greenLine( "Created #viewPath#" ); 38 | } 39 | } -------------------------------------------------------------------------------- /commands/fw1/install.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * FW/1 Commands - Install FW/1 3 | */ 4 | component displayname="FW/1 Commands - Install FW/1" 5 | excludeFromHelp=false 6 | { 7 | public string function run( boolean dev = false ) { 8 | dev 9 | ? command( "install" ).params( id = "fw1-dev", directory = fileSystemUtil.resolvePath( getCWD() ) ).run() 10 | : command( "install" ).params( id = "fw1", directory = fileSystemUtil.resolvePath( getCWD() ) ).run(); 11 | } 12 | } -------------------------------------------------------------------------------- /commands/fw1/version.cfc: -------------------------------------------------------------------------------- 1 | /** 2 | * FW/1 Commands Version Info 3 | */ 4 | component displayname="FW/1 Commands Version Info" 5 | excludeFromHelp=false 6 | { 7 | property name="settings" inject='commandbox:moduleSettings:fw1-commands'; 8 | 9 | public string function run() { 10 | return "FW/1 Commands Version #settings.version#"; 11 | } 12 | } -------------------------------------------------------------------------------- /resources/skeletons/Basic.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1-commands/79e5cd1ed8de68bb8d8785b460959547f55273de/resources/skeletons/Basic.zip -------------------------------------------------------------------------------- /resources/skeletons/Examples.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1-commands/79e5cd1ed8de68bb8d8785b460959547f55273de/resources/skeletons/Examples.zip -------------------------------------------------------------------------------- /resources/skeletons/Skeleton.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1-commands/79e5cd1ed8de68bb8d8785b460959547f55273de/resources/skeletons/Skeleton.zip -------------------------------------------------------------------------------- /resources/skeletons/Subsystem-Legacy.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1-commands/79e5cd1ed8de68bb8d8785b460959547f55273de/resources/skeletons/Subsystem-Legacy.zip -------------------------------------------------------------------------------- /resources/skeletons/Subsystem.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1-commands/79e5cd1ed8de68bb8d8785b460959547f55273de/resources/skeletons/Subsystem.zip -------------------------------------------------------------------------------- /resources/templates/SubsystemTemplate.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/framework-one/fw1-commands/79e5cd1ed8de68bb8d8785b460959547f55273de/resources/templates/SubsystemTemplate.zip --------------------------------------------------------------------------------