-
Notifications
You must be signed in to change notification settings - Fork 117
Commands, Generators, and Tasks
tower new <app-name> [options]
tower server
Note:
node serverworks well and is pure node.
Use the Tower.js console to programmatically mess around with your application data.
tower console
You can also run the console in CoffeeScript!
tower console -c
tower generate <generator> [args] [options]
See the available Generators for details on how to use them.
tower generate module my-library
Tower comes with a full application skeleton generator similar to the Rails variant. To use the app generator, simply execute the following in a console.
tower new my-app
The generated application will have the following structure:
|-- app
| |-- client
| | |-- stylesheets
| | | `-- application.stylus
| | |-- config
| | | `-- assets.coffee
| |-- controllers
| | `-- applicationController.coffee
| |-- models
| |-- views
| | |-- layouts
| | | `-- application.coffee
| | |-- index.coffee
| `-- helpers
| | `-- applicationHelper.coffee
|-- Cakefile
|-- config
| |-- application.coffee
| |-- environments
| | |-- development.coffee
| | |-- production.coffee
| | `-- test.coffee
| |-- locale
| | `-- en.coffee
| |-- routes.coffee
| |-- database.coffee
|-- lib
|-- package.json
|-- public
| |-- favicon.ico
| |-- humans.txt
| `-- robots.txt
|-- README.md
|-- spec
| |-- helper.coffee
| |-- models
| `-- acceptance
`-- vendor
| |-- javascripts
| | |-- tower.js
| | |-- underscore.js
| `-- stylesheets
`-- Watchfile
The following options are currently supported:
--javascripts <format> Format for JavaScripts (coffee, js)
--stylesheets <format> Format for StyleSheets (styl, less, css)
--views <format> Format for Views (coffee, jade, mustache)
--database <type> Database type (mongodb, memory, sqlite3)
--test <framework> Testing framework (jasmine, vows, qunit, assert)
--docs <format> Documentation format (md, markdown, textile, txt)
-v, --version Output the version number
-h, --help Output usage information
In a future release Tower will likely support a --locales option.
tower generate scaffold Post title:string body:text belongsTo:user
Generates:
|-- app
| |-- controllers
| | | `-- usersController.coffee
| |-- models
| | | `-- user.coffee
| |-- views
| | |-- users
| | | `-- _form.coffee
| | | `-- edit.coffee
| | | `-- index.coffee
| | | `-- new.coffee
| | | `-- show.coffee
| `-- helpers
| | | `-- userHelper.coffee
`-- spec
| |-- models
| | | `-- userSpec.coffee
tower generate model Post title:string body:text belongsTo:user
Generates:
|-- app
| |-- models
| | | `-- post.coffee
The Post model generated:
class App.Post extends Tower.Model
@field "id", type: "Id"
@field "title"
@field "body"
@belongs_to "user", type: "User", foreignKey: "userId"
@field "createdAt", type: "Time", default: -> new Date()tower generate view Post title:string body:text belongsTo:user
Generates:
|-- app
| |-- views
| | |-- users
| | | `-- _form.coffee
| | | `-- edit.coffee
| | | `-- index.coffee
| | | `-- new.coffee
| | | `-- show.coffee
To create a Controller for the User model, execute the Controller Generator like this:
tower generate controller Post
The controller should generate a single controller file:
|-- app
| |-- controllers
| | | `-- postsController.coffee
The controller will initially be empty:
class App.PostsController extends Tower.ControllerFill it out as needed:
class App.PostsController extends Tower.Controller
@respondTo "html", "json"
new: ->
@posts = Post.all()