Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We use Brunch as the client-side application assembler: http://brunch.io/Image Removed

  • Brunch

...

  • was used to create the application skeleton for Ambari Web.
  • Brunch builds and deploys code automatically in the background as you modify the source files. This lets you break up the application into a number of JS files for code organization and reuse without worrying about development turnaround or runtime load performance.

...

  • Easily run unit tests
  • Run a Node.js-based web server with a single command so that you can easily run the application from the application root directory without any special configuration.

To check out Ambari Web from the Github repository and run it:

...

  • Execute the following:
    Code Block
    
    git clone 

...

  • git://git.apache.org/ambari.git
    cd ambari-web
    

...

  • npm install -g brunch
    npm install
    

To run the web server (and to enable continuous build/deploy), runin isolation with Ambari Server:

Code Block
brunch watch --server

...

 (or use the shorthand: brunch w \--s)

The above runs Ambari Web at localhost:3333.

  • Recommended IDE: PhpStorm

All front-end developers should are highly recommended to use PhpStorm by JetBrains. JetBrains has kindly granted all contributors of Apache Ambari a free license for PhpStorm and IntelliJ (if you also need to do Java development - IntelliJ is a superset of PhpStorm, but PhpStorm is lighter so it is recommended if you are not modifying Java code).

...

Go to Preferences->Plugins->Browse repositories and install “Node.js” and “Handlebars” plugins.

Coding Conventions

Before checking in For any HTMLJavaScript/JavaScriptHandlebars/CSS LESS files, they must should be formatted with the IDE to maintain consistency.
Also, the IDE will give warnings in the editor about implicit globals, etc. Fix these warnings before checking in codesubmitting patches.

IDE Code Formatting Customization

We will use all default settings for Code Style in the IDE, except for the following:

Code Block
Go to Preferences
Code Style->General
Line separator (for new files): Unix
Make sure “Use tab character” is NOT checked
Tab size: 2
Indent: 2
Continuation indent: 2
Code Style->JavaScript:
Tabs and Indents
Make sure “use tab character” is NOT checked

...


Set Tab size, Indent, and Continuation indent to “2”.

...


Spaces->Other

...


Turn on “After name-value property separator ‘:’

In general, the following conventions should be followed for all JavaScript code: http://javascript.crockford.com/code.htmlImage Removed

Exceptions to the rule from the above:

  • We use 2 spaces instead of 4.
  • Variable Declarations:
    “It is preferred that each variable be given its own line and comment. They should be listed in alphabetical order.”
    Comment only where it makes sense. - No need to do alphabetical sorting.
  • “JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.” - This does not need to be followed.
  • Unit Testing

Unit tests are written using Mocha.
Run unit tests via:

Code Block

brunch test

Ambari Backend Development

...