Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
jwanga committed Jan 18, 2015
1 parent d70b3a2 commit 4fb732a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 198 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ coverage
manifest.mf
build.xml
server.js
node_modules
npm-debug.log

.project
.settings
.idea/
*/node_modules
167 changes: 59 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,130 +1,81 @@
# angular-sprout — The scalable angular seed app
This project modifies the standard angular-seed project into a module pattern in which common
functionality is organized into the same directory. This approach seperates controllers, services,
filters and directives into their own files and strives to keep the application hierachy as flat
as possible.
Angular Sprout exists to give developers the simplest possible best practices base on which to build scalable angular applications. Its worth noting that, though minimal, Angular Sprout is highly opinionated and is not everything to everyone, or anyone for that matter.

The app contains AngularJS libraries, test libraries and a bunch of scripts all preconfigured for
instant web development gratification. Just clone the repo (or download the zip/tarball), start up
our (or yours) webserver and you are ready to develop and test your application.
## Running Angular-Sprout
- Point your webserver of choice to the root.
- Yahtzee!!

The sprout app doesn't do much, just shows how to wire controllers, views, services, filters and directives together. You can
check it out by opening app/index.html in your browser (might not work file `file://` scheme in
certain browsers, see note below).
## Running Tests
- Run npm to install dev dependancies.
```
npm install
```
- Run Karma
```
karma start karma-unit-config.js
```

_Note: While angular is client-side-only technology and it's possible to create angular webapps that
don't require a backend server at all, we recommend hosting the project files using a local
webserver during development to avoid issues with security restrictions (sandbox) in browsers. The
sandbox implementation varies between browsers, but quite often prevents things like cookies, xhr,
etc to function properly when an html page is opened via `file://` scheme instead of `http://`._
## Flatten Directories
Keeping the directory hierachy flat makes it easy find files. I believe is using name convention to organize files leads to a more navigable hierarchy.

- The major module types: controllers, services, filters, contants, directives, etc get their own folders because the end up containing many cross cutting concerns.
- Application folders (controllers, etc...) and configuration folders (data, etc...) live at the same level in the hierearchy. Use your build tool (grunt, etc..) to prepare deplyment folders.

## How to use angular-sprout
## Module files.
Each instance of an angular module gets its own file. Monolithic controler, services, etc... are a potential maintenance nightmare.

Clone the angular-sprout repository and start hacking...
## Test files.
Placing tests adjecent to tested modules makes it easier to find corresponding tests.

## Namespaces
giving each module type its own namespace off of a common one clarifies the sepeartion of concers, preserves the global scope and saves one having to instantiate anguar modues in every file.

### Running the app during development
```
var Application = Application || {};
You can pick one of these options:
Application.Constants = angular.module('application.constants', []);
Application.Services = angular.module('application.services', []);
Application.Controllers = angular.module('application.controllers', []);
Application.Filters = angular.module('application.filters', []);
Application.Directives = angular.module('application.directives', []);
```

* serve this repository with your webserver
* install node.js and run `scripts/web-server.js`

Then navigate your browser to `http://localhost:<port>/app/index.html` to see the app running in
your browser.


### Running the app in production

This really depends on how complex is your app and the overall infrastructure of your system, but
the general rule is that all you need in production are all the files under the `app/` directory.
Everything else should be omitted.

Angular apps are really just a bunch of static html, css and js files that just need to be hosted
somewhere, where they can be accessed by browsers.

If your Angular app is talking to the backend server via xhr or other means, you need to figure
out what is the best way to host the static files to comply with the same origin policy if
applicable. Usually this is done by hosting the files by the backend server or through
reverse-proxying the backend server(s) and a webserver(s).


### Running unit tests

We recommend using [jasmine](http://pivotal.github.com/jasmine/) and
[Testacular](http://vojtajina.github.com/testacular/) for your unit tests/specs, but you are free
to use whatever works for you.

Requires [node.js](http://nodejs.org/), Testacular (`sudo npm install -g testacular`) and a local
or remote browser.

* start `scripts/test.sh` (on windows: `scripts\test.bat`)
* a browser will start and connect to the Testacular server (Chrome is default browser, others can be captured by loading the same url as the one in Chrome or by changing the `config/testacular.conf.js` file)
* to run or re-run tests just change any of your source or test javascript files


### End to end testing
## Directory Layout

Angular ships with a baked-in end-to-end test runner that understands angular, your app and allows
you to write your tests with jasmine-like BDD syntax.
constants/ --> Application constants.
configuration-constants.js

Requires a webserver, node.js + `./scripts/web-server.js` or your backend server that hosts the angular static files.
controllers/
details-controller.js
menu-controller.js

Check out the
[end-to-end runner's documentation](http://docs.angularjs.org/guide/dev_guide.e2e-testing) for more
info.
data/ --> Folder for mock data
items.json

* create your end-to-end tests in `/e2e/*-e2e.js`
* serve your project directory with your http/backend server or node.js + `scripts/web-server.js`
* run the tests from console with [Testacular](vojtajina.github.com/testacular) via
`scripts/e2e-test.sh` or `script/e2e-test.bat`
direcives/
menu-item-directive.js

filters/
to-datetime-string.js

### Receiving updates from upstream
libraries/ --> angular and 3rd party javascript libraries
angular.js
angular.min.js
angular-*.js

When we upgrade angular-sprout repo with newer angular or testing library code, you can just
fetch the changes and merge them into your project with git.
services/
menu-service.js

templates/ --> All view, directive and include templates.
details-template.html
menu-template.html
menu-item-template.html

## Directory Layout
styles/
application.css

app/ --> all of the files to be used in production
application/ --> application module
application.css --> default stylesheet
application.js --> application bootstrap
configuration-service.js --> application wide settings
date-time/ --> date-time module
to-datetime-string.css --> default stylesheet
details/ --> details module
details-controller.js --> details view controller
details-partial.js --> details view partial
error/ --> details module
error-controller.js --> error view controller
error-partial.js --> error view partial
menu/ --> menu module
menu-controller.js --> menu control controller
menu-partial.js --> menue control partial
menu-service.js --> menu control service
menu-item-directive.js --> menu item control directive
menu-item-template.html --> menu item directive template
items.json --> item data
index.html --> app layout file (the main html template file of the app)
lib/ --> angular and 3rd party javascript libraries
angular.js --> the latest angular js
angular.min.js --> the latest minified angular js
angular-*.js --> angular add-on modules

config/testacular.conf.js --> config file for running unit tests with Testacular
config/testacular-e2e.conf.js --> config file for running e2e tests with Testacular

scripts/ --> handy shell/js/ruby scripts
e2e-test.sh --> runs end-to-end tests with Testacular (*nix)
e2e-test.bat --> runs end-to-end tests with Testacular (windows)
test.bat --> autotests unit tests with Testacular (windows)
test.sh --> autotests unit tests with Testacular (*nix)
web-server.js --> simple development webserver based on node.js
e2e/ --> end to end tests are defined at the tob level as they are notbased on units of code.
home-e2e.html --> end-to-end tests for the home page
layout-e2e.js --> end to end test to verify the layout
index.html --> Application layout file (the main html template file of the app)
application.js --> application bootstrap
karma-unit.config.js --> Unit test Karma configuration files.
package.json --> Node dev dependancies.
20 changes: 0 additions & 20 deletions config/testacular-scenario.conf.js

This file was deleted.

27 changes: 0 additions & 27 deletions config/testacular-unit.conf.js

This file was deleted.

18 changes: 0 additions & 18 deletions scenario/home-test.js

This file was deleted.

24 changes: 0 additions & 24 deletions scenario/layout-test.js

This file was deleted.

0 comments on commit 4fb732a

Please sign in to comment.