|Josh Habdas d4807b1167 pass or fail||5 years ago|
|app||5 years ago|
|generators||5 years ago|
|jakelib||5 years ago|
|server||5 years ago|
|test||5 years ago|
|vendor||6 years ago|
|.editorconfig||6 years ago|
|.gitignore||6 years ago|
|.travis.yml||5 years ago|
|CHANGELOG.md||5 years ago|
|Jakefile||6 years ago|
|LICENSE||5 years ago|
|README.md||5 years ago|
|bower.json||5 years ago|
|brunch-config.coffee||5 years ago|
|package.json||5 years ago|
BWP is a skeleton for building web applications, specifically single-page applications. It is a modification of btc-chaplin. It leverages node, Brunch, Scaffolt, Bower, Hapi, PhantomJS, Karma, and Jake to provide cross-platform tasks in a simple package. EditorConfig is also provided to help with consistency.
It contains the following differences from its upstream:
For a mobile/Cordova friendly variant, check out this skeleton.
├── app # App is built here. Look at Brunch for more info. │ ├── assets # Static files that are just copied │ ├── controllers # Chaplin controllers │ ├── lib # Chaplin utilities and helpers │ ├── models # Chaplin models and collections │ ├── styles # Application style rule declarations │ │ ├── _base.scss # Sass variables and mixins for the application │ │ └── application.scss # Application/page styling definition │ ├── views # Chaplin views and collection views │ ├── application.coffee # Chaplin application definition │ ├── initialize.coffee # Application initialization and script loaders │ ├── config.coffeeenv # Environment-specific variables │ └── routes.coffee # Route definitions for Chaplin ├── bower_components # Packages installed by Bower ├── generators # Generators used by Scaffolt ├── jakelib # Unified set of tasks for development ├── node_modules # Packages installed by NPM ├── public # Generated final product ├── server # Server configuration ├── test # Test-related files │ ├── assets # Static assets to run code tests manually │ ├── code # Code-based tests for Karma/manual │ ├── site # Site-based tests for Mocha and WebDriverJS │ ├── karma.conf.coffee # Karma configuration for code tests │ ├── mocha.opts # Default options for site tests │ └── setup.js # Configuration for site tests ├── vendor # 3rd party JS/CSS libraries ├── .editorconfig # EditorConfig definition file for coding styles ├── bower.json # Listing for Bower dependencies to download ├── brunch-config.js # Brunch app build configuration └── package.json # Project dependencies and configuration
npm installto install all package dependencies.
jake server:devto download Bower dependencies and start the server.
jake command is not available in path, execute
npm install -g jake to install it globally.
One-line commands are provided for convenience as well for those that want to start running things as quickly as possible by installing depedencies automatically. Use
npm start to download non-development packages and run the
build:prod task. Use
npm test to download all packages and run both the
A basic push state server serving static assets is included by default. You can expand/enhance the server as needed for services and to create a more ambitious application.
When making a pull request, make sure to edit the base fork to which you want to contribute (by default it will try and merge with the parent repository from which this one is forked, which we don’t want to do).
While Brunch/Scaffolt/etc. can be used, Jake commands are provided for a simple and consistent interface. These tasks can be executed using
jake [task]) These are the following available tasks provided out of the box:
Download and preinstall any Bower dependencies in advance. You can run this if you want to download Bower dependencies in advance.
Remove downloaded Bower dependencies. This is useful if you want to reinstall dependencies. (e.g. updated package)
Locks down Node package versions.
Remove downloaded Node dependencies. This is useful if you want to reinstall dependencies. (e.g. updated package)
These commands add additional features/items to the project that are not included by default.
Add/remove jQuery to/from the project.
Add/remove Lo-Dash to/from the project.
Add/remove Rivets.js to/from the project for binding models and views. No additional configuration is needed if added. To reference a model from a view with rivets use the
model object. To access model properties from Rivets by default use
model:name equates to
Add/remove Swag helpers for Handlebars templates.
Add/remove Exoskeleton to/from the project for a more lightweight Backbone. Note that this removes/restores classic Backbone, jQuery, and Lo-Dash. You can use other tasks to add/remove jQuery and Lo-Dash again.
Add/remove Davy to/from the project for simple and lightweight Promise support. Add this if you are using Exoskeleton and want support for promises.
Scaffolding commands are available in the form of
del. (syntax ex:
jake gen codetest=user) Multiple scaffolds can be specified in a single command, as well as separating names with commas. (ex:
jake gen codetest=test1,test2 sitetest=test3) Unit test files are automatically generated for Chaplin items. For Chaplin views, a template and stylesheet is also provided in addition to the code file.
List available scaffolds.
Generate/destroy a Chaplin model.
Generate/destroy a Chaplin collection. Generating a Chaplin collection will also generate its corresponding model. Specify the name in singular form, as collection will automatically be pluralized.
Generate/destroy a Chaplin view.
Generate/destroy a Chaplin collection view. Generating a Chaplin collection view will also generate the individual item view.
Generate/destroy a Chaplin controller.
Generate/destroy a test file with the given test name for testing code. (ex: unit testing)
Generate/destroy a test file with the given test name for testing the site. (ex: functional testing)
Testing commands are available via Jake as defined below. Run
npm test to automatically install and run tests.
Install dependencies for tests. Omitted from package for speedier installs.
test:all [codereporter=progress] [sitereporter=spec]
Run all tests listed below once. For more information on reporters see below.
test:code [reporter=progress] [watch=false]
Run code-based tests (ex. unit tests) using Karma. Karma is preconfigured out of the box to run with PhantomJS and detected browsers. A Karma reporter can be specified with the
reporter option. If you run this task with
watch=true Karma will auto-run on file changes. Otherwise by default Karma runs once. In addition, if you run a build (see below) with the
dev environment the tests are included with a reporter under
test to run in browsers. (ex. visit
test:site [reporter=spec] [watch=false]
Run site-based tests (ex. system tests) using Mocha and WebDriverJS. A Brunch server is started up temporarily to interact with the site. A Mocha reporter can be specified with the
reporter option. If you run this task with
watch=true Mocha will auto-run on file changes with nodemon. Otherwise by default Mocha runs once. The global method
getDriver is provided to get a setup and built driver. WebDriverJS’ use of Promises can be combined with Mocha as Promised to handle asynchronous behavior easily. ex:
describe 'Sample', -> before -> @driver = getDriver() it 'Has a proper title', -> @driver.get('http://localhost:3333').then => @driver.getTitle() .then (title) -> expect(title).to.equal('Chapless Brunch') after -> @driver.quit()
These commands are used to assemble the application, generating the necessary JS/CSS and adding assets. Use
dev mode to keep readable JS/CSS, plus include source maps as well as tests under the
test folder. Use
prod mode to minify/uglify JS/CSS as well as omit source maps and tests. If any Bower dependencies have not been downloaded yet, Bower will first download them.
Assemble the application once.
Assemble the application and continue to watch for changes. Rebuild every time a change is detected.
Assemble the application and continue to watch for changes. Rebuild every time a change is detected. Also, the application is served locally to open with a browser. This build uses the
config.coffeeenv file is provided in the
app directory. It allows you to set environment variables for the purposes of local development or deployment.
(env) -> # Environment options # https://github.com/rcs/jsenv-brunch/ environmentOpts = API_HOST: 'http://api.apihost.com' # Set allowed environment options for key, value of env switch key when 'API_HOST' then environmentOpts.API_HOST = value environmentOpts
This allows you to run a command with the environment variable:
API_HOST="http://api.untappd.com" jake watch:dev
And access passed variables as a CommonJS module at runtime:
config = require('config') console.log config.API_URL # => http://api.untappd.com