EVOLUTION-MANAGER
Edit File: contribute.html
<a href='https://github.com/angular/angular.js/edit/v1.3.x/docs/content/misc/contribute.ngdoc?message=docs(misc%2FDevelop)%3A%20describe%20your%20change...' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit"> </i>Improve this Doc</a> <h1 id="building-and-testing-angularjs">Building and Testing AngularJS</h1> <p>This document describes how to set up your development environment to build and test AngularJS, and explains the basic mechanics of using <code>git</code>, <code>node</code>, <code>npm</code>, <code>grunt</code>, and <code>bower</code>.</p> <p>See the <a href="https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md">contributing guidelines</a> for how to contribute your own code to AngularJS.</p> <ol> <li><a href="misc/contribute#installing-dependencies">Installing Dependencies</a></li> <li><a href="misc/contribute#forking-angular-on-github">Forking Angular on Github</a></li> <li><a href="misc/contribute#building-angularjs">Building AngularJS</a></li> <li><a href="misc/contribute#running-a-local-development-web-server">Running a Local Development Web Server</a></li> <li><a href="misc/contribute#running-the-unit-test-suite">Running the Unit Test Suite</a></li> <li><a href="misc/contribute#running-the-end-to-end-test-suite">Running the End-to-end Test Suite</a></li> </ol> <h2 id="installing-dependencies">Installing Dependencies</h2> <p>Before you can build AngularJS, you must install and configure the following dependencies on your machine:</p> <ul> <li><p><a href="http://git-scm.com/">Git</a>: The <a href="https://help.github.com/articles/set-up-git">Github Guide to Installing Git</a> is a good source of information.</p> </li> <li><p><a href="http://nodejs.org">Node.js</a>: We use Node to generate the documentation, run a development web server, run tests, and generate distributable files. Depending on your system, you can install Node either from source or as a pre-packaged bundle.</p> </li> <li><p><a href="http://www.java.com">Java</a>: We minify JavaScript using our <a href="https://developers.google.com/closure/">Closure Tools</a> jar. Make sure you have Java (version 7 or higher) installed and included in your <a href="http://docs.oracle.com/javase/tutorial/essential/environment/paths.html">PATH</a> variable.</p> </li> <li><p><a href="http://gruntjs.com">Grunt</a>: We use Grunt as our build system. Install the grunt command-line tool globally with:</p> <pre><code class="lang-shell">npm install -g grunt-cli </code></pre> </li> <li><p><a href="http://bower.io/">Bower</a>: We use Bower to manage client-side packages for the docs. Install the <code>bower</code> command-line tool globally with:</p> <pre><code class="lang-shell">npm install -g bower </code></pre> </li> </ul> <p><strong>Note:</strong> You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to install Grunt & Bower globally.</p> <h2 id="forking-angular-on-github">Forking Angular on Github</h2> <p>To create a Github account, follow the instructions <a href="https://github.com/signup/free">here</a>. Afterwards, go ahead and <a href="http://help.github.com/forking">fork</a> the <a href="https://github.com/angular/angular.js">main AngularJS repository</a>.</p> <h2 id="building-angularjs">Building AngularJS</h2> <p>To build AngularJS, you clone the source code repository and use Grunt to generate the non-minified and minified AngularJS files:</p> <pre><code class="lang-shell"># Clone your Github repository: git clone "git@github.com:<github username>/angular.js.git" # Go to the AngularJS directory: cd angular.js # Add the main AngularJS repository as an upstream remote to your repository: git remote add upstream "https://github.com/angular/angular.js.git" # Install node.js dependencies: npm install # Install bower components: bower install # Build AngularJS: grunt package </code></pre> <div class="alert alert-warning"> <strong>Note:</strong> If you're using Windows, you must use an elevated command prompt (right click, run as Administrator). This is because <code>grunt package</code> creates some symbolic links. </div> <div class="alert alert-warning"> <strong>Note:</strong> If you're using Linux, and npm install fails with the message 'Please try running this command again as root/Administrator.', you may need to globally install grunt and bower: <ul> <li>sudo npm install -g grunt-cli</li> <li>sudo npm install -g bower</li> </ul> </div> <p>The build output can be located under the <code>build</code> directory. It consists of the following files and directories:</p> <ul> <li><p><code>angular-<version>.zip</code> — The complete zip file, containing all of the release build artifacts.</p> </li> <li><p><code>angular.js</code> — The non-minified <code>angular</code> script.</p> </li> <li><p><code>angular.min.js</code> — The minified <code>angular</code> script.</p> </li> <li><p><code>angular-scenario.js</code> — The <code>angular</code> End2End test runner.</p> </li> <li><p><code>docs/</code> — A directory that contains all of the files needed to run <code>docs.angularjs.org</code>.</p> </li> <li><p><code>docs/index.html</code> — The main page for the documentation.</p> </li> <li><p><code>docs/docs-scenario.html</code> — The End2End test runner for the documentation application.</p> </li> </ul> <h2 id="running-a-local-development-web-server">Running a Local Development Web Server</h2> <p>To debug code and run end-to-end tests, it is often useful to have a local HTTP server. For this purpose, we have made available a local web server based on Node.js.</p> <ol> <li><p>To start the web server, run:</p> <pre><code class="lang-shell">grunt webserver </code></pre> </li> <li><p>To access the local server, enter the following URL into your web browser:</p> <pre><code class="lang-text">http://localhost:8000/ </code></pre> <p>By default, it serves the contents of the AngularJS project directory.</p> </li> <li><p>To access the locally served docs, visit this URL:</p> <pre><code class="lang-text">http://localhost:8000/build/docs/ </code></pre> </li> </ol> <h2 id="running-the-unit-test-suite">Running the Unit Test Suite</h2> <p>We write unit and integration tests with Jasmine and execute them with Karma. To run all of the tests once on Chrome run:</p> <pre><code class="lang-shell">grunt test:unit </code></pre> <p>To run the tests on other browsers (Chrome, ChromeCanary, Firefox, Opera and Safari are pre-configured) use:</p> <pre><code class="lang-shell">grunt test:unit --browsers Opera,Firefox </code></pre> <p>Note there should be <em>no spaces between browsers</em>. <code>Opera, Firefox</code> is INVALID.</p> <p>During development it's however more productive to continuously run unit tests every time the source or test files change. To execute tests in this mode run:</p> <ol> <li><p>To start the Karma server, capture Chrome browser and run unit tests, run:</p> <pre><code class="lang-shell">grunt autotest </code></pre> </li> <li><p>To capture more browsers, open this URL in the desired browser (URL might be different if you have multiple instance of Karma running, read Karma's console output for the correct URL):</p> <pre><code class="lang-text">http://localhost:9876/ </code></pre> </li> <li><p>To re-run tests just change any source or test file.</p> </li> </ol> <p>To learn more about all of the preconfigured Grunt tasks run:</p> <pre><code class="lang-shell">grunt --help </code></pre> <h2 id="running-the-end-to-end-test-suite">Running the End-to-end Test Suite</h2> <p>Angular's end to end tests are run with Protractor. Simply run:</p> <pre><code class="lang-shell">grunt test:e2e </code></pre> <p>This will start the webserver and run the tests on Chrome.</p>